I have mappers configured for "main" and "child", and those tables are 
linked on main.childid=child.childid.  How can I use in() to get rows where 
child.othercolumn is in a list of values?  I'd like to do something like:

foo = session.query(MainTable).filter_by(customer='CUSTNAME')
foo = foo.filter(ChildTable.c.othercolumn.in_('bar', 'baz', 'qux'))

Or, even better, some variant on:

foo = session.query(MainTable).filter_by(customer='CUSTNAME')
foo = foo.filter(othercolumn in ('bar', 'baz', 'qux'))

When I try to do that, though, I get SQL like:

SELECT main.value AS main_value, main.childid AS main_childid, child.childid
AS child_childid, child.othercolumn AS child_othercolumn
FROM testing.main, testing.child
WHERE child.othercolumn IN (%(child_othercolumn)s, %(child_othercolumn_1)s,
%(child_othercolumn_2)s) ORDER BY main.value

which is really doing a cartesian join and never enforcing 
main.childid=child.childid.  Is there another way I should be approaching 
this?
-- 
Kirk Strauser

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to