On Jan 3, 2013, at 2:40 AM, jo wrote: > Hi all, > > I need to use in_(), but in oracle it has a limit of 1000 values, > there's an alternative syntax that can be used successful in oracle and it is: > (field,-1) in ( (123,-1), (333,-1), ... ) > > I tryed this: > session.query(Mytable).filter((Mytable.c.id,-1).in_([(123,-1),(333,-1)]) ) > > AttributeError: 'tuple' object has no attribute 'in_' > > How can I use this syntax with sa?
I usually handle the Oracle 1000 value limit by running the same query multiple times, then merging in memory. But if you want to do (a, b) IN ((x1, y1), (x2, y2), ...) there's a construct called tuple_() that should do it: >>> from sqlalchemy import tuple_ >>> print tuple_(mytable.c.id, -1).in_([tuple_(1, -1), tuple_(2, -1)]) (t.x, :param_1) IN ((:param_2, :param_3), (:param_4, :param_5)) -- 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.
