but what happens if i say:
q.select(or_(User.c.orders.items.item_name == 'item#4',
User.c.orders.items.item_name == 'item #5'))
if we naively convert c.orders.items.item_name=='item #4' into
"user.user_id=orders.user_id and orders.order_id=items.order_id and
items.item_name='item #4", then the other clause for item #5
generates into the same thing and you get an inefficient query. i
wonder also if some expressions above dont work correctly if the join
conditions are repeated like that.
its still better to say:
q.select(or_(Item.c.item_name == 'item#4', Item.c.item_name == 'item
#5'), from_obj=[c.orders.items])
isnt it ? (User.c.orders.items would be a synonym for query.join_via
('orders', 'items'))
On Nov 9, 2006, at 12:38 AM, Michael Bayer wrote:
>
>
> On Nov 8, 2006, at 10:00 PM, Daniel Miller wrote:
>> q = session.query(User)
>> c = getcols(User)
>>
>> q.select(
>> (c.addresses.street == 'some address') &
>> (c.orders.items.item_name == 'item #4')
>> )
>>
>
> ohhhhhh, wow. heh. i had this discomfort with adding relationships
> to "c", but then you just wrapped up the whole mess of join_to/
> join_via into one consistent syntax there, didnt you. youll notice
> in the docs for join_to/join_via theyre marked with "alpha
> API" (meaning I have been antsy with them anyway)....so this syntax
> is compelling.
>
> you have to pipe in more often Dan !
>
>
>
>
>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---