Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10248 -- Corrected handling of the GROUP BY clause when using …

…a DateQuerySet. Thanks to Alex Gaynor for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9839 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2b1bb716ff7552bf9f98653c172a573c380e4798 1 parent fb64ea7
Russell Keith-Magee authored February 16, 2009
2  django/db/models/sql/query.py
@@ -389,7 +389,7 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
389 389
                 # other than MySQL), then any fields mentioned in the
390 390
                 # ordering clause needs to be in the group by clause.
391 391
                 if not self.connection.features.allows_group_by_pk:
392  
-                    grouping.extend([col for col in ordering_group_by
  392
+                    grouping.extend([str(col) for col in ordering_group_by
393 393
                         if col not in grouping])
394 394
             else:
395 395
                 ordering = self.connection.ops.force_no_ordering()
4  tests/regressiontests/aggregation_regress/models.py
@@ -213,6 +213,10 @@ def __unicode__(self):
213 213
 >>> books.all()
214 214
 [<Book: Artificial Intelligence: A Modern Approach>, <Book: Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp>, <Book: Practical Django Projects>, <Book: Python Web Development with Django>, <Book: Sams Teach Yourself Django in 24 Hours>, <Book: The Definitive Guide to Django: Web Development Done Right>]
215 215
 
  216
+# Regression for #10248 - Annotations work with DateQuerySets
  217
+>>> Book.objects.annotate(num_authors=Count('authors')).filter(num_authors=2).dates('pubdate', 'day')
  218
+[datetime.datetime(1995, 1, 15, 0, 0), datetime.datetime(2007, 12, 6, 0, 0)]
  219
+
216 220
 """
217 221
 }
218 222
 

0 notes on commit 2b1bb71

Please sign in to comment.
Something went wrong with that request. Please try again.