Django

Code

Ticket #1777 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

sqlite backend has small bug in date conversion

Reported by: dart@google.com Assigned to: adrian
Milestone: Component: Database layer (models, ORM)
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Here's a diff for the sqlite backend I was just experiencing. Part of the problem was that the tables were created with a different ORM (sqlobject) that uses a different name for the time stamp. It also need another flag to read it.

Index: django/db/backends/sqlite3/base.py

===================================================================

--- django/db/backends/sqlite3/base.py (revision 2832)

+++ django/db/backends/sqlite3/base.py (working copy)

@@ -11,6 +11,8 @@

Database.register_converter("time", util.typecast_time) Database.register_converter("date", util.typecast_date) Database.register_converter("datetime", util.typecast_timestamp)

+Database.register_converter("timestamp", util.typecast_timestamp) +Database.register_converter("TIMESTAMP", util.typecast_timestamp)

def utf8rowFactory(cursor, row):

def utf8(s):

@@ -35,7 +37,9 @@

def cursor(self):

from django.conf import settings if self.connection is None:

- self.connection = Database.connect(settings.DATABASE_NAME, detect_types=Database.PARSE_DECLTYPES) + self.connection = Database.connect(settings.DATABASE_NAME, + detect_types=Database.PARSE_DECLTYPES|Database.PARSE_COLNAMES) +

# register extract and date_trun functions self.connection.create_function("django_extract", 2, _sqlite_extract) self.connection.create_function("django_date_trunc", 2, _sqlite_date_trunc)

Attachments

django_sqlite.diff (1.2 kB) - added by dart@google.com on 05/05/06 14:09:09.
diff from svn

Change History

05/05/06 14:09:09 changed by dart@google.com

  • attachment django_sqlite.diff added.

diff from svn

05/05/06 22:27:50 changed by adrian

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

(In [2851]) Fixed #1777 -- Fixed bug in date conversion in SQLite backend. Thanks, dart@google.com


Add/Change #1777 (sqlite backend has small bug in date conversion)




Change Properties
Action