Ticket #10248: annotate-dates.diff

File annotate-dates.diff, 1.6 KB (added by Alex Gaynor, 16 years ago)
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    index bf664c6..372579d 100644
    a b class BaseQuery(object):  
    386386                # other than MySQL), then any fields mentioned in the
    387387                # ordering clause needs to be in the group by clause.
    388388                if not self.connection.features.allows_group_by_pk:
    389                     grouping.extend([col for col in ordering_group_by
     389                    grouping.extend([str(col) for col in ordering_group_by
    390390                        if col not in grouping])
    391391            else:
    392392                ordering = self.connection.ops.force_no_ordering()
  • tests/regressiontests/aggregation_regress/models.py

    diff --git a/tests/regressiontests/aggregation_regress/models.py b/tests/regressiontests/aggregation_regress/models.py
    index fc2c44b..61a8dd3 100644
    a b FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta  
    206206>>> books.all()
    207207[<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>]
    208208
     209>>> Book.objects.annotate(num_authors=Count('authors')).filter(num_authors=2).dates('pubdate', 'day')
     210[datetime.datetime(1995, 1, 15, 0, 0), datetime.datetime(2007, 12, 6, 0, 0)]
     211
    209212"""
    210213}
    211214
Back to Top