Fixed #12608 -- No longer return inconsistent results when using `values` and `values_list` in conjunction with `annotate`. Thanks, Charlie Leifer.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12505 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Justin Bronn 2010-02-23 05:26:49 +00:00
parent c4699b0b8a
commit 5546430304
3 changed files with 6 additions and 1 deletions

View File

@ -289,6 +289,7 @@ answer newbie questions, and generally made Django that much better:
Christopher Lenz <http://www.cmlenz.net/> Christopher Lenz <http://www.cmlenz.net/>
lerouxb@gmail.com lerouxb@gmail.com
Piotr Lewandowski <piotr.lewandowski@gmail.com> Piotr Lewandowski <piotr.lewandowski@gmail.com>
Charlie Leifer <coleifer@gmail.com>
Justin Lilly <justinlilly@gmail.com> Justin Lilly <justinlilly@gmail.com>
Waylan Limberg <waylan@gmail.com> Waylan Limberg <waylan@gmail.com>
limodou limodou

View File

@ -954,7 +954,8 @@ class ValuesListQuerySet(ValuesQuerySet):
# If a field list has been specified, use it. Otherwise, use the # If a field list has been specified, use it. Otherwise, use the
# full list of fields, including extras and aggregates. # full list of fields, including extras and aggregates.
if self._fields: if self._fields:
fields = self._fields fields = list(self._fields) + filter(lambda f: f not in self._fields,
aggregate_names)
else: else:
fields = names fields = names

View File

@ -362,4 +362,7 @@ True
>>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values_list('mean_age', flat=True) >>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values_list('mean_age', flat=True)
[34.5] [34.5]
>>> Book.objects.values_list('price').annotate(count=Count('price')).order_by('-count', 'price')
[(Decimal('29.69'), 2), (Decimal('23.09'), 1), (Decimal('30'), 1), (Decimal('75'), 1), (Decimal('82.8'), 1)]
"""} """}