diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-08-01 16:16:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-01 16:16:28 +0200 |
| commit | c9b9a52edc66be117c6e5b5214fa788a4d5db7a8 (patch) | |
| tree | 86bededa12bf9d2d6c441c0fe4fc1a35b0af796b /django/db/models/sql | |
| parent | 5a3725594faacc412e2d2b4ed160370228f1a118 (diff) | |
Fixed #34750 -- Fixed QuerySet.count() when grouping by unused multi-valued annotations.
Thanks Toan Vuong for the report.
Thanks Simon Charette for the review.
Regression in 59bea9efd2768102fc9d3aedda469502c218e9b7.
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/query.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index ac735012f1..220ae92754 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -498,6 +498,11 @@ class Query(BaseExpression): annotation_mask |= expr.get_refs() for aggregate in aggregates.values(): annotation_mask |= aggregate.get_refs() + # Avoid eliding expressions that might have an incidence on + # the implicit grouping logic. + for annotation_alias, annotation in self.annotation_select.items(): + if annotation.get_group_by_cols(): + annotation_mask.add(annotation_alias) inner_query.set_annotation_mask(annotation_mask) # Add aggregates to the outer AggregateQuery. This requires making |
