diff options
author | Simon Charette <charette.s@gmail.com> | 2022-10-18 17:31:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 17:31:45 -0700 |
commit | d62563cbb194c420f242bfced52b37d6638e67c6 (patch) | |
tree | be2e41a3b8401040712d9452d8fa5861339880ac /django/db/models/sql/compiler.py | |
parent | 78470043ae4b8def7914badcd05bb1877c8a0aa4 (diff) | |
download | django-d62563cbb194c420f242bfced52b37d6638e67c6.tar.gz |
Fixed #34105 -- Fixed crash of ordering by nested selected expression.
This stops ordering by nested selected references. It's not supported on
PostgreSQL and not required to support psycopg3.
Regression in 04518e310d4552ff7595a34f5a7f93487d78a406.
Thanks Matt Westcott for the report.
Diffstat (limited to 'django/db/models/sql/compiler.py')
-rw-r--r-- | django/db/models/sql/compiler.py | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 32b88c8960..3097500be4 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -445,11 +445,6 @@ class SQLCompiler: """ result = [] seen = set() - replacements = { - expr: Ref(alias, expr) - for alias, expr in self.query.annotation_select.items() - } - for expr, is_ref in self._order_by_pairs(): resolved = expr.resolve_expression(self.query, allow_joins=True, reuse=None) if not is_ref and self.query.combinator and self.select: @@ -478,7 +473,7 @@ class SQLCompiler: q.add_annotation(expr_src, col_name) self.query.add_select_col(resolved, col_name) resolved.set_source_expressions([RawSQL(f"{order_by_idx}", ())]) - sql, params = self.compile(resolved.replace_expressions(replacements)) + sql, params = self.compile(resolved) # Don't add the same column twice, but the order direction is # not taken into account so we strip it. When this entire method # is refactored into expressions, then we can check each part as we |