summaryrefslogtreecommitdiff
path: root/django/db/models/sql/compiler.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2022-11-23 09:50:26 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-04 08:32:27 +0100
commit0d3ccf7512edd48ac2461b7140977c16ee479d3e (patch)
tree67d69ed49cd4f25f7d1e79facac009fc2246c670 /django/db/models/sql/compiler.py
parent0b78ac3fc7bd9f0c57518d0c1a153582318edd59 (diff)
downloaddjango-0d3ccf7512edd48ac2461b7140977c16ee479d3e.tar.gz
Simplified SQLCompiler.get_group_by() a bit.
Diffstat (limited to 'django/db/models/sql/compiler.py')
-rw-r--r--django/db/models/sql/compiler.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index b9722268ed..41c5c9044f 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -128,7 +128,7 @@ class SQLCompiler:
# If the group by is set to a list (by .values() call most likely),
# then we need to add everything in it to the GROUP BY clause.
# Backwards compatibility hack for setting query.group_by. Remove
- # when we have public API way of forcing the GROUP BY clause.
+ # when we have public API way of forcing the GROUP BY clause.
# Converts string references to expressions.
for expr in self.query.group_by:
if not hasattr(expr, "as_sql"):
@@ -148,9 +148,7 @@ class SQLCompiler:
continue
if alias:
aliased_exprs[expr] = alias
- cols = expr.get_group_by_cols()
- for col in cols:
- expressions.append(col)
+ expressions.extend(expr.get_group_by_cols())
if not self._meta_ordering:
for expr, (sql, params, is_ref) in order_by:
# Skip references to the SELECT clause, as all expressions in