From 4480eea62225951263892831190012dcea10c2e0 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 28 Jan 2012 13:33:05 -0500 Subject: - [bug] Raise an exception if xyzload_all() is used inappropriately with two non-connected relationships. [ticket:2370] --- lib/sqlalchemy/orm/interfaces.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index 7f2875e5a..bda48cbb1 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -568,7 +568,12 @@ class PropertyOption(MapperOption): "mapper option expects " "string key or list of attributes") assert prop is not None + if raiseerr and not prop.parent.common_parent(mapper): + raise sa_exc.ArgumentError("Attribute '%s' does not " + "link from element '%s'" % (token, path_element)) + path = build_path(path_element, prop.key, path) + l.append(path) if getattr(token, '_of_type', None): path_element = mapper = token._of_type @@ -580,8 +585,6 @@ class PropertyOption(MapperOption): "refer to a mapped entity" % (token, entity) ) - if path_element: - path_element = path_element if current_path: # ran out of tokens before -- cgit v1.2.1