diff options
| author | Simon Charette <charette.s@gmail.com> | 2023-02-18 01:11:51 -0500 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2023-02-18 18:42:49 -0500 |
| commit | f91e085c3054240dbb581c1db9b4a9063c26525c (patch) | |
| tree | f62d3af96fba3e2e34bc0a84e60d8a3732cb09e5 /django/db/models/sql/compiler.py | |
| parent | a6511bc23329f1d3939571ad01d3176f8f6cb786 (diff) | |
Refs #34176 -- Adjusted group by position variables naming to follow SQL spec.
This avoids conceptual collisions with the notion of indices.
Diffstat (limited to 'django/db/models/sql/compiler.py')
| -rw-r--r-- | django/db/models/sql/compiler.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index c07076d54a..db123a2516 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -142,10 +142,10 @@ class SQLCompiler: # Note that even if the group_by is set, it is only the minimal # set to group by. So, we need to add cols in select, order_by, and # having into the select in any case. - selected_expr_indices = {} - for index, (expr, _, alias) in enumerate(select, start=1): + selected_expr_positions = {} + for ordinal, (expr, _, alias) in enumerate(select, start=1): if alias: - selected_expr_indices[expr] = index + selected_expr_positions[expr] = ordinal # Skip members of the select clause that are already explicitly # grouped against. if alias in group_by_refs: @@ -174,9 +174,9 @@ class SQLCompiler: continue if ( allows_group_by_select_index - and (select_index := selected_expr_indices.get(expr)) is not None + and (position := selected_expr_positions.get(expr)) is not None ): - sql, params = str(select_index), () + sql, params = str(position), () else: sql, params = expr.select_format(self, sql, params) params_hash = make_hashable(params) |
