From d8c12d9f180eeed9d2c5174eeb0c74169a04262f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 9 Nov 2021 15:02:44 -0500 Subject: set within_columns_clause=False for all sub-elements of select() Fixed issue where using the feature of using a string label for ordering or grouping described at :ref:`tutorial_order_by_label` would fail to function correctly if used on a :class:`.CTE` construct, when the CTE were embedded inside of an enclosing :class:`_sql.Select` statement that itself was set up as a scalar subquery. Fixes: #7269 Change-Id: Ied6048a1c9a622374a418230c8cfedafa8d3f87e (cherry picked from commit 89661c1a218b7117c1835698dbb81836e72015ae) --- lib/sqlalchemy/sql/compiler.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 7db8d6b5d..0f2b5e717 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -3217,6 +3217,9 @@ class SQLCompiler(Compiled): # passed in. for ORM use this will convert from an ORM-state # SELECT to a regular "Core" SELECT. other composed operations # such as computation of joins will be performed. + + kwargs["within_columns_clause"] = False + compile_state = select_stmt._compile_state_factory( select_stmt, self, **kwargs ) -- cgit v1.2.1