mirror of
https://github.com/django/django.git
synced 2025-12-02 00:01:29 +00:00
Fixed #11881 -- removed junk from aggregation subqueries
There were clauses that weren't needed in the subqueries. These were ORDER BY, SELECT FOR UPDATE and related selections.
This commit is contained in:
parent
7737305a4f
commit
7bc57a6d71
2 changed files with 26 additions and 1 deletions
|
|
@ -330,8 +330,16 @@ class Query(object):
|
|||
from django.db.models.sql.subqueries import AggregateQuery
|
||||
query = AggregateQuery(self.model)
|
||||
obj = self.clone()
|
||||
relabels = dict((t, 'subquery') for t in self.tables)
|
||||
if not force_subq:
|
||||
# In forced subq case the ordering and limits will likely
|
||||
# affect the results.
|
||||
obj.clear_ordering(True)
|
||||
obj.clear_limits()
|
||||
obj.select_for_update = False
|
||||
obj.select_related = False
|
||||
obj.related_select_cols = []
|
||||
|
||||
relabels = dict((t, 'subquery') for t in self.tables)
|
||||
# Remove any aggregates marked for reduction from the subquery
|
||||
# and move them to the outer AggregateQuery.
|
||||
for alias, aggregate in self.aggregate_select.items():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue