Code

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7420 closed (fixed)

Further generalization of DB backend (mis)features

Reported by: ramiro Owned by: adrian
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 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by ramiro

comment:1 Changed 6 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Further generalization of DB backed (mis)features to Further generalization of DB backend (mis)features

comment:2 Changed 6 years ago by adrian

  • Owner changed from nobody to adrian
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 6 years ago by adrian

  • Resolution set to fixed
  • Status changed from assigned to closed

(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 6 years ago 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 Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.