Suppose I have two classes ChildA and ChildB which both have a relationship to Parent.
Suppose also that I already have two queries defined, qa and qb, which query the respective child classes.
I want to join qb onto qa upon having the same parent.
If parent were just an ordinary column, I could do the following:
subquery = qb.subquery()
joined_query = qa.join(subquery, AliasedChildA.parent==subquery.columns.parent)
Here, AliasedChildA is an alias of ChildA. (I have full control over how the queries are being created, but not over the filters that are being applied to them later.)
But now, since parent is a relationship, it is not contained in subquery.columns.
How can I join qa and qb upon having the same parent?