From 9727cdecbe52b86b4328b92d7e10a7193ca8083e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 29 May 2021 10:05:20 -0400 Subject: Ensure propagate_attrs available on PropComparator Fixed regression caused by just-released performance fix mentioned in #6550 where a query.join() to a relationship could produce an AttributeError if the query were made against non-ORM structures only, a fairly unusual calling pattern. In this fix, since we are no longer going through the production of ``__clause_element__()`` for Cls.some_relationship, I assumed we just throw this object away completely but I missed the one little bit where we might be getting ``_propagate_attrs`` from it. So we implement ``_propagate_attrs`` on ``PropComparator`` as well, since this is easy to define. Fixes: #6558 Change-Id: If781bf844e7e3d3b0841aff1c3668e9d6af9f097 --- lib/sqlalchemy/orm/interfaces.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/sqlalchemy/orm/interfaces.py') diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index ed38becf7..c9a601f99 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -425,6 +425,18 @@ class PropComparator(operators.ColumnOperators): compatible with QueryableAttribute.""" return inspect(self._parententity).mapper + @property + def _propagate_attrs(self): + # this suits the case in coercions where we don't actually + # call ``__clause_element__()`` but still need to get + # resolved._propagate_attrs. See #6558. + return util.immutabledict( + { + "compile_state_plugin": "orm", + "plugin_subject": self._parentmapper, + } + ) + @property def adapter(self): """Produce a callable that adapts column expressions -- cgit v1.2.1