any two mappers with a common parent (this affects
whether or not aliased=True is required when joining
with Query).
+
+ - made some fixes to the "from_joinpoint" argument to
+ query.join() so that if the previous join was aliased
+ and this one isn't, the join still happens successfully.
- assorted "cascade deletes" fixes:
- Fixed "cascade delete" operation of dynamic
adapt_against = self.table
elif start.select_table is not start.mapped_table: # in the middle of a join, look for a polymorphic mapper
adapt_against = start.select_table
+ elif self._aliases: # joining against aliases
+ adapt_against = self._aliases.alias
else:
adapt_against = None
def test_overlapping_paths_outerjoin(self):
result = create_session().query(User).outerjoin(['orders', 'items']).filter_by(id=3).outerjoin(['orders','address']).filter_by(id=1).all()
assert [User(id=7, name='jack')] == result
+
+ def test_from_joinpoint(self):
+ sess = create_session()
+
+ for oalias,ialias in [(True, True), (False, False), (True, False), (False, True)]:
+ self.assertEquals(
+ sess.query(User).join('orders', aliased=oalias).join('items', from_joinpoint=True, aliased=ialias).filter(Item.description == 'item 4').all(),
+ [User(name='jack')]
+ )
+ # use middle criterion
+ self.assertEquals(
+ sess.query(User).join('orders', aliased=oalias).filter(Order.user_id==9).join('items', from_joinpoint=True, aliased=ialias).filter(Item.description=='item 4').all(),
+ []
+ )
+
+
+
def test_generative_join(self):
# test that alised_ids is copied
sess = create_session()