On Jul 27, 2010, at 9:59 PM, Kalium wrote: > I'm trying to determine whether or not there are any value in one > mapped object relation that correspond to another mapped object > relation > > i.e > A.x - represents a relation of x's on A > B.x - represents a relation of x's on B > > They both use their own separate mapping tables for these relations. > So I want to find out of any of A.x is also present in B.x
how about query(x).filter(x.a_id==my_a.id).filter(x.b_id==my_b.id) ? thats assuming you're starting with a particular A and B. > > The closes I've had to it working was in the follwing fashion, by > doing the following; > > exists([1],from_obj=join(A_x_mapping_table,B_x_mapping_table, > > onclause=A_x_mapping_table.c.id==B_x_mapping_table.c.id)) > > I put this exists clause into an existing filter() but it didn't > correlate the tables with those in the outer query (which I really > need it to do!), so I tried using correlate function to correlate the > table on the join() but it didn't seem to do anything (I've used it in > other situations with success but not this time). > > Also , A.x.any(B.x.any()) > seems to almost do what I want as well, but again, doesn't correlate > to outer query and because I'm using 0.4 it does not have a > correlate() method in ORM! > > Any other hints as to how I can do this ? > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
