diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-02-01 18:16:39 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-02-03 09:34:14 -0500 |
commit | d995af71980b1f887f2f374580d1341d72cc3442 (patch) | |
tree | ab5c754f9b25e5e0448e5aa69cc92713e88a9bbb /lib/sqlalchemy/orm/context.py | |
parent | d84e6f8f3c6a346daaa021440a6804ce37f3cb56 (diff) | |
download | sqlalchemy-d995af71980b1f887f2f374580d1341d72cc3442.tar.gz |
Fixed regression when using from_statement in orm context.
Fixed regression when using :meth:`_sql.Select.from_statement` in an ORM
context, where matching of columns to SQL labels based on name alone was
disabled for ORM-statements that weren't fully textual. This would prevent
arbitrary SQL expressions with column-name labels from matching up to the
entity to be loaded, which previously would work within the 1.4
and previous series, so the previous behavior has been restored.
Fixes: #9217
Change-Id: I5f7ab9710a96a98241388883365e56d308b4daf2
Diffstat (limited to 'lib/sqlalchemy/orm/context.py')
-rw-r--r-- | lib/sqlalchemy/orm/context.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py index 890f3382b..0e631e66f 100644 --- a/lib/sqlalchemy/orm/context.py +++ b/lib/sqlalchemy/orm/context.py @@ -731,19 +731,13 @@ class ORMFromStatementCompileState(ORMCompileState): # those columns completely, don't interfere with the compiler # at all; just in ORM land, use an adapter to convert from # our ORM columns to whatever columns are in the statement, - # before we look in the result row. If the inner statement is - # not ORM enabled, assume looser col matching based on name - statement_is_orm = ( - self.statement._propagate_attrs.get( - "compile_state_plugin", None - ) - == "orm" - ) + # before we look in the result row. Always adapt on names + # to accept cases such as issue #9217. self._from_obj_alias = ORMStatementAdapter( _TraceAdaptRole.ADAPT_FROM_STATEMENT, self.statement, - adapt_on_names=not statement_is_orm, + adapt_on_names=True, ) return self |