I'm trying to figure out the correct way to use these array comparisons features specific to postgres, e.g.:
select * from foo where 1 = any(bar); So I tried this: from sqlalchemy.sql.expression import func session.query(foo).filter(1 == func.any(foo.c.bar)) But that didn't work, as I got this (essentially): select * from foo where any(bar) = 1; Well, then I tried this: from sqlalchemy.sql.expression import func, literal session.query(foo).filter(literal(1) == func.any(foo.c.bar)) And that was better: select * from foo where 1 = any(bar); Unfortunately I really wanted something like this: select * from foo where not 1 = any(bar); So I tried this: from sqlalchemy.sql.expression import func, literal, not_ session.query(foo).filter(not_(literal(1) == func.any(foo.c.bar))) Which gave me this: select * from foo where 1 != any(bar); Which is not correct. Of course I could do this: from sqlalchemy.sql.expression import func, literal, not_ session.query(foo).filter(not_(literal(1) == func.all(foo.c.bar))) But I should really ask here for help because I've loaded the foot-gun completely full. So, what's the "correct" way to do this? -Ryan Kelly -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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.