Author: russellm
Date: 2009-02-16 06:38:11 -0600 (Mon, 16 Feb 2009)
New Revision: 9839

Modified:
   django/trunk/django/db/models/sql/query.py
   django/trunk/tests/regressiontests/aggregation_regress/models.py
Log:
Fixed #10248 -- Corrected handling of the GROUP BY clause when using a 
DateQuerySet. Thanks to Alex Gaynor for the report and patch.

Modified: django/trunk/django/db/models/sql/query.py
===================================================================
--- django/trunk/django/db/models/sql/query.py  2009-02-16 12:29:31 UTC (rev 
9838)
+++ django/trunk/django/db/models/sql/query.py  2009-02-16 12:38:11 UTC (rev 
9839)
@@ -389,7 +389,7 @@
                 # other than MySQL), then any fields mentioned in the
                 # ordering clause needs to be in the group by clause.
                 if not self.connection.features.allows_group_by_pk:
-                    grouping.extend([col for col in ordering_group_by
+                    grouping.extend([str(col) for col in ordering_group_by
                         if col not in grouping])
             else:
                 ordering = self.connection.ops.force_no_ordering()

Modified: django/trunk/tests/regressiontests/aggregation_regress/models.py
===================================================================
--- django/trunk/tests/regressiontests/aggregation_regress/models.py    
2009-02-16 12:29:31 UTC (rev 9838)
+++ django/trunk/tests/regressiontests/aggregation_regress/models.py    
2009-02-16 12:38:11 UTC (rev 9839)
@@ -213,6 +213,10 @@
 >>> books.all()
 [<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>]
 
+# Regression for #10248 - Annotations work with DateQuerySets
+>>> 
Book.objects.annotate(num_authors=Count('authors')).filter(num_authors=2).dates('pubdate',
 'day')
+[datetime.datetime(1995, 1, 15, 0, 0), datetime.datetime(2007, 12, 6, 0, 0)]
+
 """
 }
 


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to