summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-06-07 17:47:07 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-06-07 17:48:55 -0400
commitbface2e2fae834246729e539646ce229b8a113d1 (patch)
treeed4572be7043a1d4f8e3a20300cd92ad4bf89a5a /lib/sqlalchemy/sql/selectable.py
parent94169108cdd4dace09b752a6af4f4404819b49a3 (diff)
downloadsqlalchemy-bface2e2fae834246729e539646ce229b8a113d1.tar.gz
repair Join.is_derived_from() to not rely on simple identity
Fixed issue where query production for joinedload against a complex left hand side involving joined-table inheritance could fail to produce a correct query, due to a clause adaption issue. Fixes: #6595 Change-Id: Id4b839d52447cdc103b392dd8946c4cfa7a829e1
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
-rw-r--r--lib/sqlalchemy/sql/selectable.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index e24585fa0..1610191d1 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -1115,7 +1115,9 @@ class Join(roles.DMLTableRole, FromClause):
def is_derived_from(self, fromclause):
return (
- fromclause is self
+ # use hash() to ensure direct comparison to annotated works
+ # as well
+ hash(fromclause) == hash(self)
or self.left.is_derived_from(fromclause)
or self.right.is_derived_from(fromclause)
)