﻿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
11975	invalid sql returned from django.db.backends.sqlite3.DatabaseOperations.date_trunc_sql	akonsu@…	Fabián Ezequiel Gallina	"this method returns 'django_date_trunc(""<precision>"", <field>)'. in sqlite3, double quoted strings are identifiers, and string literals are single quoted (see http://www.sqlite.org/lang_keywords.html). so it should return ""django_date_trunc('<precision>', <field>)"". this breaks code such as the following:

{{{
MyModel.objects.extra(select={'year':connection.ops.date_trunc_sql('year', '""mymodel"".""date""')}).values('year').order_by().annotate(total=Count('pk')) 
}}}

the resulting query:
{{{
[{'time': '0.007', 'sql': u'SELECT (django_date_trunc(""year"", ""mymodel"".""date"")) AS ""year"", COUNT(""mymodel"".""id"") AS ""total"" FROM ""mymodel"" GROUP BY django_date_trunc(""year"", ""mymodel"".""date"")'}] 
}}}

same problem exists with date_extract_sql()
"		closed	Database layer (models, ORM)	dev		fixed	sqlite DatabaseOperations pycamp2010 djangosprint famaf		Accepted	1	0	0	0	0	0
