diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-05-29 10:05:20 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-05-29 10:10:14 -0400 |
commit | 9727cdecbe52b86b4328b92d7e10a7193ca8083e (patch) | |
tree | 51cf0647c398720e3e0eb46869b71b463bb36fb7 /test/orm/test_joins.py | |
parent | 3edc30fce3717b48407f37de958f5b6e6d0bc549 (diff) | |
download | sqlalchemy-9727cdecbe52b86b4328b92d7e10a7193ca8083e.tar.gz |
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
Diffstat (limited to 'test/orm/test_joins.py')
-rw-r--r-- | test/orm/test_joins.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/orm/test_joins.py b/test/orm/test_joins.py index 50fa86107..7f6e1b72e 100644 --- a/test/orm/test_joins.py +++ b/test/orm/test_joins.py @@ -6,6 +6,7 @@ from sqlalchemy import desc from sqlalchemy import exc as sa_exc from sqlalchemy import ForeignKey from sqlalchemy import func +from sqlalchemy import inspect from sqlalchemy import Integer from sqlalchemy import lateral from sqlalchemy import literal_column @@ -307,6 +308,25 @@ class JoinTest(QueryTest, AssertsCompiledSQL): "WHERE users.name = :name_1", ) + def test_join_relationship_propagate_attrs(self): + """test #6558""" + + User = self.classes.User + users = self.tables.users + + stmt = select(users).join(User.addresses) + + eq_( + stmt._propagate_attrs, + {"compile_state_plugin": "orm", "plugin_subject": inspect(User)}, + ) + + self.assert_compile( + stmt, + "SELECT users.id, users.name FROM users " + "JOIN addresses ON users.id = addresses.user_id", + ) + def test_invalid_kwarg_join(self): User = self.classes.User sess = fixture_session() |