Django

Code

Ticket #7420 (closed: fixed)

Opened 6 months ago

Last modified 6 months ago

Further generalization of DB backend (mis)features

Reported by: ramiro Assigned to: adrian
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords: databasefeatures database operations microseconds oracle mysql
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The patch attached:

  • Adds four new atttibutes to DatabaseFeatures (also setting the correct values for the backends bundled with Django):
supports_usecs # default value: True
time_field_needs_date # default value: False
interprets_empty_strings_as_nulls # default value: False
date_field_supports_time_value # default value: True
  • Moves prep_for_like_query from a global lambda form at django/db/backends/__init__.py) to a method of DatabaseOperations
  • Modifies contrib/sessions/backends/db.py and django/db/models/fields/__init__.py to use them instead of tests of the style if settings.DATABASE_BACKEND == 'oracle':....

If I understand things correctly this is a desirable thing to have.

Additionally this would allow moving forward with a MS SQL Server (that shares one trait with Oracle and another with MySQL and that has a particular LIKE query syntax) as a truly external backends i.e. reducing the need to patch Django itself to a minimum.

Tested with the Django trunk test suite on a Debian Etch -based environment:

  • pysqlite2 2.3.2 + sqlite 3.3.8
  • MySQLdb 1.2.1 + MySQL 5.0.32
  • psycopg2 2.0.5 + PostgreSQL 8.1.11

(no Oracle installation at hand :( but hopefully somebody will be able test with that backend and report below)

Attachments

db-be-features-r7583.diff (9.2 kB) - added by ramiro on 06/11/08 09:25:21.

Change History

06/11/08 09:25:21 changed by ramiro

  • attachment db-be-features-r7583.diff added.

06/11/08 09:28:14 changed by ramiro

  • needs_better_patch changed.
  • summary changed from Further generalization of DB backed (mis)features to Further generalization of DB backend (mis)features.
  • needs_tests changed.
  • needs_docs changed.

06/15/08 22:02:38 changed by adrian

  • owner changed from nobody to adrian.
  • status changed from new to assigned.
  • stage changed from Unreviewed to Accepted.

06/15/08 22:15:04 changed by adrian

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [7643]) Fixed #7420 -- Abstracted some more database options into DatabaseFeatures? -- supports_usecs, time_field_needs_date, interprets_empty_strings_as_nulls and date_field_supports_time_value -- and changed various hard-coded 'if DATABASE_BACKEND == oracle' statements to use the new options. Thanks to ramiro for the patch

06/15/08 22:16:29 changed by adrian

Note to ramiro: I didn't include the change to django/contrib/sessions/backends/db.py, as I wasn't sure what that was doing. If this is a problem, please open a new ticket with that as a separate patch, with an explanation of why it's needed.


Add/Change #7420 (Further generalization of DB backend (mis)features)




Change Properties
Action