On Jul 28, 11:37 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> 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.
>
>

Opps, accidentaly replied to Michael and not the group.

I wasn't dealing with a particular A and B. I wasn't successful in
using the tables in the outer query so I merely reconstructed the
where clause in the exists query that I used to join the outer tables
in the first place, i.e

 A.x.any(B.x.any()).where(X.id == my_id)

Thanks

>
> > 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 sqlalch...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > sqlalchemy+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://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 sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to