diff options
| author | Simon Charette <charette.s@gmail.com> | 2022-11-13 23:45:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-14 05:45:33 +0100 |
| commit | 10037130c123cd747d32a14a9ba47e0c5c9a37d1 (patch) | |
| tree | d675e31eccbc93ab389b11f504f81bbe89144451 /django/db/models/sql/query.py | |
| parent | b088cc2feaac638aea91e4d3ab22d276f81630ff (diff) | |
Refs #28477 -- Fixed handling aliased annotations on aggregation.
Just like when using .annotate(), the .alias() method will generate the
necessary JOINs to resolve the alias even if not selected.
Since these JOINs could be multi-valued non-selected aggregates must be
considered to require subquery wrapping as a GROUP BY is required to
combine duplicated tuples from the base table.
Regression in 59bea9efd2768102fc9d3aedda469502c218e9b7.
Diffstat (limited to 'django/db/models/sql/query.py')
| -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 775e2668b0..c858816289 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -443,7 +443,7 @@ class Query(BaseExpression): return {} existing_annotations = { alias: annotation - for alias, annotation in self.annotation_select.items() + for alias, annotation in self.annotations.items() if alias not in added_aggregate_names } # Existing usage of aggregation can be determined by the presence of |
