diff options
author | Michael Williamson <mike@zwobble.org> | 2016-08-28 12:38:04 +0100 |
---|---|---|
committer | Michael Williamson <mike@zwobble.org> | 2016-08-28 12:38:04 +0100 |
commit | 94fe6fe05dacf6f38dd0541fd59b0ca76b440c4e (patch) | |
tree | db5c13fd44a729a2352c4ae69ac1f3c8a5abc94a /lib | |
parent | 117997cd5b849a236208cf9ea16f0f09c6962804 (diff) | |
download | sqlalchemy-pr/304.tar.gz |
Provide more informative error when joining with no entitiespr/304
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/orm/query.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index f15f4340b..592c685ca 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -2125,10 +2125,15 @@ class Query(object): left = self._entities[0].entity_zero_or_selectable if left is None: + if self._entities: + problem = "Don't know how to join from %s" % self._entities[0] + else: + problem = "No entities to join from" + raise sa_exc.InvalidRequestError( - "Don't know how to join from %s; please use " + "%s; please use " "select_from() to establish the left " - "entity/selectable of this join" % self._entities[0]) + "entity/selectable of this join" % problem) if left is right and \ not create_aliases: |