Skip to content

Commit

Permalink
[1.1.X] Fixed #12608 -- No longer return inconsistent results when us…
Browse files Browse the repository at this point in the history
…ing values and values_list in conjunction with annotate. Thanks, Charlie Leifer.

Backport of r12505 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12613 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jbronn committed Feb 26, 2010
1 parent 7c23a53 commit 499c715
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions django/db/models/query.py
Expand Up @@ -871,6 +871,8 @@ def iterator(self):
# full list of fields, including extras and aggregates.
if self._fields:
fields = self._fields
fields = list(self._fields) + filter(lambda f: f not in self._fields,
aggregate_names)
else:
fields = names

Expand Down
3 changes: 3 additions & 0 deletions tests/modeltests/aggregation/models.py
Expand Up @@ -362,4 +362,7 @@ def __unicode__(self):
>>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values_list('mean_age', flat=True)
[34.5]
>>> qs = Book.objects.values_list('price').annotate(count=Count('price')).order_by('-count', 'price')
>>> list(qs) == [(Decimal('29.69'), 2), (Decimal('23.09'), 1), (Decimal('30'), 1), (Decimal('75'), 1), (Decimal('82.8'), 1)]
True
"""}

0 comments on commit 499c715

Please sign in to comment.