﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
14016	SQLite3 problem with date comparison	anonymous	tzulberti	"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]]
"		closed	Database layer (models, ORM)	1.2		worksforme	sqlite, date comparison		Unreviewed	0	0	0	0	0	0
