Skip to content

Commit

Permalink
Fixed #10248 -- Corrected handling of the GROUP BY clause when using …
Browse files Browse the repository at this point in the history
…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
freakboy3742 committed Feb 16, 2009
1 parent fb64ea7 commit 2b1bb71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/db/models/sql/query.py
Expand Up @@ -389,7 +389,7 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
# 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()
Expand Down
4 changes: 4 additions & 0 deletions tests/regressiontests/aggregation_regress/models.py
Expand Up @@ -213,6 +213,10 @@ def __unicode__(self):
>>> 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)]
"""
}

Expand Down

0 comments on commit 2b1bb71

Please sign in to comment.