mirror of
https://github.com/django/django.git
synced 2025-08-22 03:24:21 +00:00
Fixed #28477 -- Stripped unused annotations on aggregation.
Also avoid an unnecessary pushdown when aggregating over a query that doesn't have aggregate annotations.
This commit is contained in:
parent
321ecb40f4
commit
59bea9efd2
5 changed files with 109 additions and 23 deletions
|
@ -405,6 +405,12 @@ class BaseExpression:
|
|||
)
|
||||
return clone
|
||||
|
||||
def get_refs(self):
|
||||
refs = set()
|
||||
for expr in self.get_source_expressions():
|
||||
refs |= expr.get_refs()
|
||||
return refs
|
||||
|
||||
def copy(self):
|
||||
return copy.copy(self)
|
||||
|
||||
|
@ -1167,6 +1173,9 @@ class Ref(Expression):
|
|||
# just a reference to the name of `source`.
|
||||
return self
|
||||
|
||||
def get_refs(self):
|
||||
return {self.refs}
|
||||
|
||||
def relabeled_clone(self, relabels):
|
||||
return self
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue