summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-09-01 13:50:29 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-09-01 13:50:29 +0000
commit301c3f3579ace1ef1c28067904b57dd789620eae (patch)
tree77fb81cb37510730b93f55ae9e6f1ea7f672c303 /lib/sqlalchemy
parent9c5b989cf08c3e625fc08a8c5e037c44ba465579 (diff)
parent17090c004e19afab35c837bf880ea5b328e1fb56 (diff)
downloadsqlalchemy-301c3f3579ace1ef1c28067904b57dd789620eae.tar.gz
Merge "Provide a more detailed error message for Query.join()"
Diffstat (limited to 'lib/sqlalchemy')
-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