summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-03-18 19:34:32 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-03-18 21:47:46 -0400
commitc1c999c01d595b74fe178d9bdbff34fd8939a283 (patch)
tree7b6c7d0395096c29b43fcbbe6c4c5f8a7138daf8 /lib/sqlalchemy/sql/util.py
parentd0812a1abf903f6b5f1a0bfb19f8c87a665f8309 (diff)
downloadsqlalchemy-c1c999c01d595b74fe178d9bdbff34fd8939a283.tar.gz
Ensure ClauseAdapter treats FunctionElement as a ColumnElement
Fixed regression where use of an unnamed SQL expression such as a SQL function would raise a column targeting error if the query itself were using joinedload for an entity and was also being wrapped in a subquery by the joinedload eager loading process. Fixes: #6086 Change-Id: I22cf4d6974685267c4f903bd7639be8271c6c1ef
Diffstat (limited to 'lib/sqlalchemy/sql/util.py')
-rw-r--r--lib/sqlalchemy/sql/util.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index 5f35de5f0..4300d8a29 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -843,8 +843,13 @@ class ClauseAdapter(visitors.ReplacingExternalTraversal):
newcol = self.selectable.exported_columns.get(col.name)
return newcol
+ @util.preload_module("sqlalchemy.sql.functions")
def replace(self, col):
- if isinstance(col, FromClause):
+ functions = util.preloaded.sql_functions
+
+ if isinstance(col, FromClause) and not isinstance(
+ col, functions.FunctionElement
+ ):
if self.selectable.is_derived_from(col):
return self.selectable
elif isinstance(col, Alias) and isinstance(