summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-07-18 11:12:49 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-07-18 11:14:19 -0400
commit736186f840646773217d3f7ba3f6a5d0bbfe1fdb (patch)
treef81df43209df75b1ab9a992c894fc5b166834955 /lib/sqlalchemy
parentc01f90de584f50f036c5b6d0c44074b4b3014da4 (diff)
downloadsqlalchemy-736186f840646773217d3f7ba3f6a5d0bbfe1fdb.tar.gz
Fix regression for self-ref join to self error message
Fixed regression caused by :ticket:`4365` where a join from an entity to itself without using aliases no longer raises an informative error message, instead failing on an assertion. The informative error condition has been restored. Fixes: #4773 Change-Id: Iabeb56f3f0c2a40e350fd7c69f07c02dc9804c2c
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index b5c49ee05..4b176cb55 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -2467,9 +2467,11 @@ class Query(object):
use_entity_index,
) = self._join_place_explicit_left_side(left)
- # this should never happen because we would not have found a place
- # to join on
- assert left is not right or create_aliases
+ if left is right and not create_aliases:
+ raise sa_exc.InvalidRequestError(
+ "Can't construct a join from %s to %s, they "
+ "are the same entity" % (left, right)
+ )
# the right side as given often needs to be adapted. additionally
# a lot of things can be wrong with it. handle all that and