From 770e1e399cb0c91db73a551e1962ccbb57f42e76 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 15 Jun 2017 12:03:22 -0400 Subject: Repair regression to pathing for subclasses Issue #3963's initial commit narrowed the "current path" match rules too much such that a path that matches current path on subclass would no longer match. Change-Id: I8c9a0db91a09d789cfb8666288a913f8bbcdb2e9 Fixes: #3963 --- lib/sqlalchemy/orm/strategy_options.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/orm') diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py index d3f456969..4c7e34ebb 100644 --- a/lib/sqlalchemy/orm/strategy_options.py +++ b/lib/sqlalchemy/orm/strategy_options.py @@ -472,7 +472,7 @@ class _UnboundLoad(Load): def _chop_path(self, to_chop, path): i = -1 - for i, (c_token, (p_mapper, p_prop)) in enumerate( + for i, (c_token, (p_entity, p_prop)) in enumerate( zip(to_chop, path.pairs())): if isinstance(c_token, util.string_types): if i == 0 and c_token.endswith(':' + _DEFAULT_TOKEN): @@ -482,7 +482,12 @@ class _UnboundLoad(Load): return None elif isinstance(c_token, PropComparator): if c_token.property is not p_prop or \ - c_token._parententity is not p_mapper: + ( + c_token._parententity is not p_entity and ( + not c_token._parententity.is_mapper or + not c_token._parententity.isa(p_entity) + ) + ): return None else: i += 1 -- cgit v1.2.1