the "please specify primaryjoin" message when determining
join condition.
+ - When using Query.join() with an explicit clause for the
+ ON clause, the clause will be aliased in terms of the left
+ side of the join, allowing scenarios like query(Source).
+ from_self().join((Dest, Source.id==Dest.source_id)) to work
+ properly.
+
- polymorphic_union() function respects the "key" of each
Column if they differ from the column's name.
onclause = right_adapter.traverse(onclause)
if prop:
+ # MapperProperty based onclause
onclause = prop
-
+ else:
+ # ClauseElement based onclause
+ onclause = self._adapt_clause(onclause, False, True)
+
clause = orm_join(clause, right_entity, onclause, isouter=outerjoin)
if alias_criterion:
self._filter_aliases = right_adapter
else:
onclause = pj
self._target_adapter = target_adapter
-
+
expression.Join.__init__(self, left, right, onclause, isouter)
def join(self, right, onclause=None, isouter=False):
[('jack',)]
)
+ # explicit onclause with from_self(), means
+ # the onclause must be aliased against the query's custom
+ # FROM object
+ self.assertEquals(
+ sess.query(User).offset(2).from_self().join(
+ (Order, User.id==Order.user_id)
+ ).all(),
+ [User(name='fred')]
+ )
+
+ # same with an explicit select_from()
+ self.assertEquals(
+ sess.query(User).select_from(select([users]).offset(2).alias()).join(
+ (Order, User.id==Order.user_id)
+ ).all(),
+ [User(name='fred')]
+ )
+
def test_aliased_classes(self):
sess = create_session()