From bface2e2fae834246729e539646ce229b8a113d1 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 7 Jun 2021 17:47:07 -0400 Subject: 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 --- lib/sqlalchemy/sql/selectable.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') 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) ) -- cgit v1.2.1