mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #10182 -- Corrected realiasing and the process of evaluating values() for queries with aggregate clauses. This means that aggregate queries can now be used as subqueries (such as in an __in clause). Thanks to omat for the report.
This involves a slight change to the interaction of annotate() and values() clauses that specify a list of columns. See the docs for details. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9888 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -207,10 +207,9 @@ u'The Definitive Guide to Django: Web Development Done Right'
|
||||
>>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values('pk', 'isbn', 'mean_age')
|
||||
[{'pk': 1, 'isbn': u'159059725', 'mean_age': 34.5}]
|
||||
|
||||
# Calling it with paramters reduces the output but does not remove the
|
||||
# annotation.
|
||||
# Calling values() with parameters reduces the output
|
||||
>>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values('name')
|
||||
[{'name': u'The Definitive Guide to Django: Web Development Done Right', 'mean_age': 34.5}]
|
||||
[{'name': u'The Definitive Guide to Django: Web Development Done Right'}]
|
||||
|
||||
# An empty values() call before annotating has the same effect as an
|
||||
# empty values() call after annotating
|
||||
|
||||
Reference in New Issue
Block a user