[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-11 Thread Daniel Miller
BTW, this post started out as a reply to James but grew into a collective summary of my thoughts on the entire thread so far. You've been warned :) James Taylor wrote: But wouldn't the join from orders to items be OUTER in this case since you can have orders with a total 50 but no items.

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-10 Thread Michael Bayer
On Nov 9, 2006, at 10:20 PM, Daniel Miller wrote: Can you give an example of the SQL (including the joins) that would be generated by your statement above? (user.user_id=orders.user_id AND orders.order_id=items.order_id AND items.item_name='item #4') OR (user.user_id=orders.user_id AND

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-10 Thread Michael Bayer
On Nov 10, 2006, at 12:13 AM, Daniel Miller wrote: This query: q.select(or_( c.orders.items.item_name == 'item#4', c.orders.items.item_name == 'item #5' )) Should generate something similar to this SQL: SELECT ... FROM users u INNER JOIN orders o ON u.user_id =

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-09 Thread Michael Bayer
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

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-09 Thread Daniel Miller
Michael Bayer wrote: 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

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-08 Thread Daniel Miller
Michael Bayer wrote: ok let me rephrase that... i have concerns. i think the concerns could be addressed, and we might be able to add this kind of feature...but i dont want to rush into it singlehandedly. I won't blame you for that. I'll help out as much as possible given my busy

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-08 Thread Michael Bayer
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') ) ohh, wow. heh. i had this discomfort with adding relationships to c, but then you just

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-06 Thread Randall Smith
dmiller wrote: Is there a reason why this doesn't work: orders = Table('orders', meta, Column('id', Integer, Sequence('order_id_seq'), primary_key=True), ... ) items = Table('items', meta, Column('id', Integer, Sequence('item_id_seq'), primary_key=True),

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-06 Thread dmiller
On Nov 6, 2006, at 3:31 PM, Randall Smith wrote: dmiller wrote: Is there a reason why this doesn't work: ... order = session.query(Order).get(1) # assume order exists itemsNotInOrder = session.query(Item).select(Item.c.order != order) # ERROR! This should work. itemsNotInOrder =

[sqlalchemy] Re: Constructing where-clauses dynamically

2006-11-06 Thread Michael Bayer
the c namespace is only for table columns. if we wanted a namespace that had represented mapper properties, which is not just column-mapped attributes but relationships as well, that would be something else altogether. we'd have to define a whole package of expression objects that represent