Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7420 closed (fixed)

Further generalization of DB backend (mis)features

Reported by: Ramiro Morales Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: Keywords: databasefeatures database operations microseconds oracle mysql
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 (1)

db-be-features-r7583.diff (9.2 KB) - added by Ramiro Morales 8 years ago.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by Ramiro Morales

Attachment: db-be-features-r7583.diff added

comment:1 Changed 8 years ago by Ramiro Morales

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Summary: Further generalization of DB backed (mis)featuresFurther generalization of DB backend (mis)features

comment:2 Changed 8 years ago by Adrian Holovaty

Owner: changed from nobody to Adrian Holovaty
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:3 Changed 8 years ago by Adrian Holovaty

Resolution: fixed
Status: assignedclosed

(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

comment:4 Changed 8 years ago by Adrian Holovaty

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.

Note: See TracTickets for help on using tickets.
Back to Top