I'm attempting to return the overlap of the results of two ORM queries that would both return a list of integers. I have two tables and I know how to perform the simple filtered queries on them.
query1 = session.query(T1.UID).filter(T1.date < now) query2 = session.query(T2.UID).filter(T2.date < now)
What I'd like is a query that will return the UIDs that appear in both of the results that would be returned by these queries. The individual queries would return a large amount of data but I'm looking for the relatively small overlap. Conceptually something like
<result of query1>.in_(<result of query2>).