#14016: SQLite3 problem with date comparison
------------------------+---------------------------------------------------
Reporter: anonymous | Status: new
Milestone: | Component: ORM aggregation
Version: 1.2 | Keywords: sqlite, date comparison
Stage: Unreviewed | Has_patch: 0
------------------------+---------------------------------------------------
I've hit a bug using Django 1.2.1.
I've a model with date types. Django generates a query like this that
returns the correct results:
SELECT xxx FROM "table" WHERE ("table"."pub_date" >= 2010-01-24 );
If I switch to "lt" or "lte" it gives me nothing, because sqlite seems to
want "'" around the date. You can see for yourself in the following test
case run with SQLite 3.6.16 and 3.7.0.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
$ sqlite3 prova.db[[BR]]
SQLite version 3.6.16[[BR]]
Enter ".help" for instructions[[BR]]
Enter SQL statements terminated with a ";"[[BR]]
sqlite> create table foo( d date null);[[BR]]
sqlite> insert into foo(d) values( '2009-09-09' );[[BR]]
sqlite> select * from foo where (d >= 2007-01-01);[[BR]]
2009-09-09[[BR]]
sqlite> select * from foo where (d <= 2010-01-01);[[BR]]
sqlite> select * from foo where (d <= '2010-01-01');[[BR]]
2009-09-09[[BR]]
sqlite> [[BR]]
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
$ sqlite3 prova.db[[BR]]
SQLite version 3.7.0[[BR]]
Enter ".help" for instructions[[BR]]
Enter SQL statements terminated with a ";"[[BR]]
sqlite> create table foo( d date null);[[BR]]
sqlite> insert into foo(d) values( '2009-09-09' );[[BR]]
sqlite> select * from foo where (d >= 2007-01-01);[[BR]]
2009-09-09[[BR]]
sqlite> select * from foo where (d <= 2010-01-01);[[BR]]
sqlite> select * from foo where (d <= '2010-01-01');[[BR]]
2009-09-09[[BR]]
sqlite> [[BR]]
--
Ticket URL: <http://code.djangoproject.com/ticket/14016>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.