#14016 closed (worksforme)
SQLite3 problem with date comparison
Reported by: | anonymous | Owned by: | tzulberti |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.2 |
Severity: | Keywords: | sqlite, date comparison | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
SQLite version 3.6.16
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table foo( d date null);
sqlite> insert into foo(d) values( '2009-09-09' );
sqlite> select * from foo where (d >= 2007-01-01);
2009-09-09
sqlite> select * from foo where (d <= 2010-01-01);
sqlite> select * from foo where (d <= '2010-01-01');
2009-09-09
sqlite>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
$ sqlite3 prova.db
SQLite version 3.7.0
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table foo( d date null);
sqlite> insert into foo(d) values( '2009-09-09' );
sqlite> select * from foo where (d >= 2007-01-01);
2009-09-09
sqlite> select * from foo where (d <= 2010-01-01);
sqlite> select * from foo where (d <= '2010-01-01');
2009-09-09
sqlite>
Attachments (1)
Change History (4)
comment:1 by , 14 years ago
Owner: | set to |
---|
by , 14 years ago
Attachment: | ticket_14016.diff added |
---|
comment:2 by , 14 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:3 by , 12 years ago
Component: | ORM aggregation → Database layer (models, ORM) |
---|
I don't have that problem. Feel free to change the change anything.
The patch is an example I run against django code.
Models:
The test: