diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/orm/context.py | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/util.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py index 45ab64593..b0b8faee7 100644 --- a/lib/sqlalchemy/orm/context.py +++ b/lib/sqlalchemy/orm/context.py @@ -2707,7 +2707,9 @@ class _ORMColumnEntity(_ColumnEntity): compile_state._entities.append(self) compile_state._has_orm_entities = True + self.column = column + self._fetch_column = self._row_processor = None self._extra_entities = (self.expr, self.column) 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( |