summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-04-28 18:37:43 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-04-28 18:37:43 +0000
commit5eb748f39942ff34286833cd3e9146fce7bf29af (patch)
treefa2433b2f6f79afce2a71a6115866d0e649fd2d0 /lib
parentd43192cf986a192ecd8d34cb8fe845b7121cdb05 (diff)
parent483a644959f396e3abdcb8f0f373936569958970 (diff)
downloadsqlalchemy-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.py1
-rw-r--r--lib/sqlalchemy/orm/relationships.py5
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