diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2020-04-28 18:37:43 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-04-28 18:37:43 +0000 |
commit | 5eb748f39942ff34286833cd3e9146fce7bf29af (patch) | |
tree | fa2433b2f6f79afce2a71a6115866d0e649fd2d0 /lib | |
parent | d43192cf986a192ecd8d34cb8fe845b7121cdb05 (diff) | |
parent | 483a644959f396e3abdcb8f0f373936569958970 (diff) | |
download | sqlalchemy-5eb748f39942ff34286833cd3e9146fce7bf29af.tar.gz |
Merge "Alias the onclause if ORM join is to same polymorphic selectable"
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/orm/query.py | 1 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/relationships.py | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index ab49a4dcc..98e997078 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -2762,7 +2762,6 @@ class Query(Generative): elif prop: # joining to selectable with a mapper property given # as the ON clause - if not right_selectable.is_derived_from( right_mapper.persist_selectable ): diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index 6ac56a324..85f23d159 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -2377,7 +2377,10 @@ class RelationshipProperty(StrategizedProperty): if self._is_self_referential and source_selectable is None: dest_selectable = dest_selectable._anonymous_fromclause() aliased = True - elif dest_selectable is not self.mapper._with_polymorphic_selectable: + elif ( + dest_selectable is not self.mapper._with_polymorphic_selectable + or self.mapper.with_polymorphic + ): aliased = True dest_mapper = of_type_mapper or self.mapper |