diff options
| author | Simon Charette <charette.s@gmail.com> | 2020-05-14 00:14:48 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-05-14 10:26:16 +0200 |
| commit | 49bbf6570d9f0880b836f741d79e4cdb6e061ea2 (patch) | |
| tree | 105f896b7704dd50e1be44cd4049179c904e9b1d /django | |
| parent | afceb2241ba84dfafe59de326cdc9c01963ddefb (diff) | |
[3.0.x] Fixed #31568 -- Fixed alias reference when aggregating over multiple subqueries.
691def10a0197d83d2d108bd9043b0916d0f09b4 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.
Backport of adfbf653dc1c1d0e0dacc4ed46602d22ba28b004 from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/sql/query.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 329a6e16c0..f550d5e28b 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -393,7 +393,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: |
