summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/orm/context.py')
-rw-r--r--lib/sqlalchemy/orm/context.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py
index 0868fb29b..d9e334d45 100644
--- a/lib/sqlalchemy/orm/context.py
+++ b/lib/sqlalchemy/orm/context.py
@@ -1170,7 +1170,18 @@ class ORMSelectCompileState(ORMCompileState, SelectState):
if of_type:
right = of_type
else:
- right = onclause.property.entity
+ right = onclause.property
+
+ try:
+ right = right.entity
+ except AttributeError as err:
+ util.raise_(
+ sa_exc.ArgumentError(
+ "Join target %s does not refer to a "
+ "mapped entity" % right
+ ),
+ replace_context=err,
+ )
left = onclause._parententity
@@ -1312,7 +1323,18 @@ class ORMSelectCompileState(ORMCompileState, SelectState):
if of_type:
right = of_type
else:
- right = onclause.property.entity
+ right = onclause.property
+
+ try:
+ right = right.entity
+ except AttributeError as err:
+ util.raise_(
+ sa_exc.ArgumentError(
+ "Join target %s does not refer to a "
+ "mapped entity" % right
+ ),
+ replace_context=err,
+ )
left = onclause._parententity