diff options
| author | Simon Charette <charette.s@gmail.com> | 2023-04-06 08:19:53 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-04-07 06:58:24 +0200 |
| commit | 511dc3db539122577aaba71f5a24d65d5adab092 (patch) | |
| tree | 9505072d9a18f09a671f8442624fc608cb00b2c6 /django/db/models/sql/query.py | |
| parent | 4d6a92749c3e59c6d4fbff385ff04771b9f61961 (diff) | |
[4.2.x] Fixed #34464 -- Fixed queryset aggregation over group by reference.
Regression in 59bea9efd2768102fc9d3aedda469502c218e9b7.
Refs #28477.
Thanks Ian Cubitt for the report.
Backport of 9daf8b4109c3e133eb57349bb44d73cc60c5773c from main
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index bb359ae6e8..b347c6bf3f 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -453,6 +453,9 @@ class Query(BaseExpression): # filtering against window functions is involved as it # requires complex realising. annotation_mask = set() + if isinstance(self.group_by, tuple): + for expr in self.group_by: + annotation_mask |= expr.get_refs() for aggregate in aggregates.values(): annotation_mask |= aggregate.get_refs() inner_query.set_annotation_mask(annotation_mask) |
