mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #31217 -- Made QuerySet.values()/values_list() group by not selected annotations with aggregations used in order_by().
Regression in 59b4e99dd0.
Thanks Jon Dufresne for the report and Simon Charette for the review.
This commit is contained in:
@@ -123,8 +123,8 @@ class SQLCompiler:
|
||||
for expr, (sql, params, is_ref) in order_by:
|
||||
# Skip References to the select clause, as all expressions in the
|
||||
# select clause are already part of the group by.
|
||||
if not expr.contains_aggregate and not is_ref:
|
||||
expressions.extend(expr.get_source_expressions())
|
||||
if not is_ref:
|
||||
expressions.extend(expr.get_group_by_cols())
|
||||
having_group_by = self.having.get_group_by_cols() if self.having else ()
|
||||
for expr in having_group_by:
|
||||
expressions.append(expr)
|
||||
|
||||
Reference in New Issue
Block a user