summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/query.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-03-10 18:48:42 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-03-10 18:49:35 -0400
commit7d8c64f9087bcde14dc641fe75f93a04823b86d6 (patch)
treef8ca6841ebeb78a1bf3df9f3c8c1a16847ef886d /lib/sqlalchemy/orm/query.py
parent7c6bdc9f0d279be40d6f53b68a3a448b2ccfb73f (diff)
downloadsqlalchemy-7d8c64f9087bcde14dc641fe75f93a04823b86d6.tar.gz
Reword implicit left join error; ensure deterministic FROM for columns
Adjusted the error message emitted by :meth:`.Query.join` when a left hand side can't be located that the :meth:`.Query.select_from` method is the best way to resolve the issue. Also, within the 1.3 series, used a deterministic ordering when determining the FROM clause from a given column entity passed to :class:`.Query` so that the same expression is determined each time. Fixes: #5194 Change-Id: I2e4065fd31e98c57edf2f11d5e831be44d2c1ea2
Diffstat (limited to 'lib/sqlalchemy/orm/query.py')
-rw-r--r--lib/sqlalchemy/orm/query.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 796ebe3ac..fe1ea9bfc 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -2530,14 +2530,18 @@ class Query(Generative):
raise sa_exc.InvalidRequestError(
"Can't determine which FROM clause to join "
"from, there are multiple FROMS which can "
- "join to this entity. Try adding an explicit ON clause "
- "to help resolve the ambiguity."
+ "join to this entity. Please use the .select_from() "
+ "method to establish an explicit left side, as well as "
+ "providing an explcit ON clause if not present already to "
+ "help resolve the ambiguity."
)
else:
raise sa_exc.InvalidRequestError(
- "Don't know how to join to %s; please use "
- "an ON clause to more clearly establish the left "
- "side of this join" % (right,)
+ "Don't know how to join to %r. "
+ "Please use the .select_from() "
+ "method to establish an explicit left side, as well as "
+ "providing an explcit ON clause if not present already to "
+ "help resolve the ambiguity." % (right,)
)
elif self._entities:
@@ -2572,14 +2576,18 @@ class Query(Generative):
raise sa_exc.InvalidRequestError(
"Can't determine which FROM clause to join "
"from, there are multiple FROMS which can "
- "join to this entity. Try adding an explicit ON clause "
- "to help resolve the ambiguity."
+ "join to this entity. Please use the .select_from() "
+ "method to establish an explicit left side, as well as "
+ "providing an explcit ON clause if not present already to "
+ "help resolve the ambiguity."
)
else:
raise sa_exc.InvalidRequestError(
- "Don't know how to join to %s; please use "
- "an ON clause to more clearly establish the left "
- "side of this join" % (right,)
+ "Don't know how to join to %r. "
+ "Please use the .select_from() "
+ "method to establish an explicit left side, as well as "
+ "providing an explcit ON clause if not present already to "
+ "help resolve the ambiguity." % (right,)
)
else:
raise sa_exc.InvalidRequestError(