mirror of https://github.com/django/django.git
Refs #34717 -- Avoided computing aggregate refs twice.
This commit is contained in:
parent
15cb3c262a
commit
d7a9f006ed
|
@ -451,13 +451,14 @@ class Query(BaseExpression):
|
||||||
# Temporarily add aggregate to annotations to allow remaining
|
# Temporarily add aggregate to annotations to allow remaining
|
||||||
# members of `aggregates` to resolve against each others.
|
# members of `aggregates` to resolve against each others.
|
||||||
self.append_annotation_mask([alias])
|
self.append_annotation_mask([alias])
|
||||||
|
aggregate_refs = aggregate.get_refs()
|
||||||
refs_subquery |= any(
|
refs_subquery |= any(
|
||||||
getattr(self.annotations[ref], "contains_subquery", False)
|
getattr(self.annotations[ref], "contains_subquery", False)
|
||||||
for ref in aggregate.get_refs()
|
for ref in aggregate_refs
|
||||||
)
|
)
|
||||||
refs_window |= any(
|
refs_window |= any(
|
||||||
getattr(self.annotations[ref], "contains_over_clause", True)
|
getattr(self.annotations[ref], "contains_over_clause", True)
|
||||||
for ref in aggregate.get_refs()
|
for ref in aggregate_refs
|
||||||
)
|
)
|
||||||
aggregate = aggregate.replace_expressions(replacements)
|
aggregate = aggregate.replace_expressions(replacements)
|
||||||
self.annotations[alias] = aggregate
|
self.annotations[alias] = aggregate
|
||||||
|
|
Loading…
Reference in New Issue