#5555: Django fails to do .dates query on sqlite
----------------------------------------------------+-----------------------
Reporter: Vladimir Pouzanov <[EMAIL PROTECTED]> | Owner: nobody
Status: new | Component: Database
wrapper
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
----------------------------------------------------+-----------------------
{{{
In [12]: d=Post.objects.dates('date_published', 'month')
In [14]: d
Out[14]: [datetime.datetime(2007, 9, 1, 0, 0)]
In [13]: d[0]
---------------------------------------------------------------------------
<class 'sqlite3.OperationalError'> Traceback (most recent call
last)
/home/farcaller/develop/web/fw/<ipython console> in <module>()
/usr/lib/python2.5/site-packages/django/db/models/query.py in
__getitem__(self, k)
155 else:
156 try:
--> 157 return list(self._clone(_offset=k,
_limit=1))[0]
158 except self.model.DoesNotExist, e:
159 raise IndexError, e.args
/usr/lib/python2.5/site-packages/django/db/models/query.py in
__iter__(self)
112
113 def __iter__(self):
--> 114 return iter(self._get_data())
115
116 def __getitem__(self, k):
/usr/lib/python2.5/site-packages/django/db/models/query.py in
_get_data(self)
480 def _get_data(self):
481 if self._result_cache is None:
--> 482 self._result_cache = list(self.iterator())
483 return self._result_cache
484
/usr/lib/python2.5/site-packages/django/db/models/query.py in
iterator(self)
661 qn(self._field.column))), sql, group_by, self._order)
662 cursor = connection.cursor()
--> 663 cursor.execute(sql, params)
664
665 has_resolve_columns = hasattr(self, 'resolve_columns')
/usr/lib/python2.5/site-packages/django/db/backends/util.py in
execute(self, sql, params)
17 start = time()
18 try:
---> 19 return self.cursor.execute(sql, params)
20 finally:
21 stop = time()
/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/base.py in
execute(self, query, params)
127 def execute(self, query, params=()):
128 query = self.convert_query(query, len(params))
--> 129 return Database.Cursor.execute(self, query, params)
130
131 def executemany(self, query, param_list):
<class 'sqlite3.OperationalError'>: near "GROUP": syntax error
}}}
the resulting query "SELECT django_date_trunc("month",
"blog_post"."date_published") FROM "blog_post" LIMIT 1 GROUP BY 1 ORDER
BY 1 ASC" is wrong according to sqlite docs, LIMIT should go after GROUP
BY (in fact - mostly in the end).
--
Ticket URL: <http://code.djangoproject.com/ticket/5555>
Django Code <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
-~----------~----~----~----~------~----~------~--~---