Fixed #10132 -- Corrected the interaction of extra() queries with the values() clause. Thanks to Glen Maynard for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9838 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2009-02-16 12:29:31 +00:00
parent 58ea6d4561
commit fb64ea7896
3 changed files with 28 additions and 14 deletions

View file

@ -698,7 +698,7 @@ class QuerySet(object):
Prepare the query for computing a result that contains aggregate annotations.
"""
opts = self.model._meta
if not self.query.group_by:
if self.query.group_by is None:
field_names = [f.attname for f in opts.fields]
self.query.add_fields(field_names, False)
self.query.set_group_by()
@ -736,6 +736,7 @@ class ValuesQuerySet(QuerySet):
aggregate_names = self.query.aggregate_select.keys()
names = extra_names + field_names + aggregate_names
for row in self.query.results_iter():
yield dict(zip(names, row))