mirror of
https://github.com/django/django.git
synced 2025-12-02 00:01:29 +00:00
Fixed #31568 -- Fixed alias reference when aggregating over multiple subqueries.
691def10a0 made all Subquery() instances
equal to each other which broke aggregation subquery pushdown which
relied on object equality to determine which alias it should select.
Subquery.__eq__() will be fixed in an another commit but
Query.rewrite_cols() should haved used object identity from the start.
Refs #30727, #30188.
Thanks Makina Corpus for the report.
This commit is contained in:
parent
42c08ee465
commit
adfbf653dc
3 changed files with 26 additions and 2 deletions
|
|
@ -390,7 +390,7 @@ class Query(BaseExpression):
|
|||
else:
|
||||
# Reuse aliases of expressions already selected in subquery.
|
||||
for col_alias, selected_annotation in self.annotation_select.items():
|
||||
if selected_annotation == expr:
|
||||
if selected_annotation is expr:
|
||||
new_expr = Ref(col_alias, expr)
|
||||
break
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue