Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1777 closed defect (fixed)

sqlite backend has small bug in date conversion

Reported by: dart@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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

django_sqlite.diff (1.2 KB ) - added by dart@… 19 years ago.
diff from svn

Download all attachments as: .zip

Change History (2)

by dart@…, 19 years ago

Attachment: django_sqlite.diff added

diff from svn

comment:1 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

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

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