Hi, I'm looking for the SQLAlchemy equivalent to the query
SELECT *
FROM a
LEFT OUTER JOIN (b INNER JOIN c ON b.id = c.b_id)
ON a.id = b.a_id
Related:
Table "b" and "c" are joined and filtered first, then the outer join is applied. I was able to achieve the same results using a subquery, whose fields I was subsequently able to load using `contains_eager`. FYI
subq = session.query(B).join(C).subquery(with_labels=True)
q = (session.query(A)
.outerjoin(subq, A.id==subq.c.b_a_id)
.options(contains_eager(A.b, alias=subq)
.options(contains_eager(B.c, alias=subq))))
r = q.all()
I'm curious whether there's an equivalent using the above nested join syntax.
Thanks.