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:
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(
# of FROMs for the overall expression - this helps
# subqueries which were built from ORM constructs from
# leaking out their entities into the main select construct
- self.actual_froms = actual_froms = set(column._from_objects)
+ self.actual_froms = list(column._from_objects)
+ actual_froms = set(self.actual_froms)
if not search_entities:
self.entity_zero = _entity
if self.entity_zero is not None:
return self.entity_zero
elif self.actual_froms:
- return list(self.actual_froms)[0]
+ return self.actual_froms[0]
else:
return None
if "selectable" not in self.__dict__:
self.selectable = ext_info.selectable
- if self.actual_froms.intersection(ext_info.selectable._from_objects):
+ if set(self.actual_froms).intersection(
+ ext_info.selectable._from_objects
+ ):
self.froms.add(ext_info.selectable)
def corresponds_to(self, entity):
assert_raises_message(
sa.exc.InvalidRequestError,
- "Don't know how to join to .*Item.*; "
- "please use an ON clause to more clearly establish the "
- "left side of this join",
+ "Don't know how to join to .*Item.*. "
+ r"Please use the .select_from\(\) "
+ "method to establish an explicit left side, as well as",
q.join,
Item,
)
assert_raises_message(
sa.exc.InvalidRequestError,
- "Don't know how to join to .*Item.*; "
- "please use an ON clause to more clearly establish the "
- "left side of this join",
+ "Don't know how to join to .*Item.*. "
+ r"Please use the .select_from\(\) "
+ "method to establish an explicit left side, as well as",
q.join,
Item,
)
assert_raises_message(
sa.exc.InvalidRequestError,
- "Don't know how to join to .*Item.*; "
- "please use an ON clause to more clearly establish the "
- "left side of this join",
+ "Don't know how to join to .*Item.*. "
+ r"Please use the .select_from\(\) "
+ "method to establish an explicit left side, as well as",
q.join,
Item,
)
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.",
+ r"Please use the .select_from\(\) "
+ "method to establish an explicit left side, as well as",
q.join,
a1,
)
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.",
+ r"Please use the .select_from\(\) "
+ "method to establish an explicit left side, as well as",
q.join,
a1,
)
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.",
+ r"Please use the .select_from\(\) "
+ "method to establish an explicit left side, as well as",
q.outerjoin,
a1,
)
assert_raises_message(
sa_exc.InvalidRequestError,
- "Don't know how to join to .*User.* please use an ON clause to ",
+ "Don't know how to join to .*User.*. "
+ r"Please use the .select_from\(\) "
+ "method to establish an explicit left side, as well as",
sess.query(users.c.id).join,
User,
)
assert_raises_message(
sa_exc.InvalidRequestError,
- "Don't know how to join to .*User.* please use an ON clause to ",
+ "Don't know how to join to .*User.* "
+ r"Please use the .select_from\(\) "
+ "method to establish an explicit left side, as well as",
sess.query(users.c.id).select_from(users).join,
User,
)