mirror of
https://github.com/django/django.git
synced 2025-09-24 19:23:03 +00:00
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:
parent
58ea6d4561
commit
fb64ea7896
3 changed files with 28 additions and 14 deletions
|
@ -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))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue