Thanks very much for your help! We'll plan to use a workaround now and
revisit the issue when 1.2 comes out.
There are a couple subtleties that may be of interest. Compiling to 0 or 1
has the effect of removing all syntactic references to the original
expression from the query. This is anomalous and had the effect of
confusing some tooling we have that uses SQLAlchemy to generate (but not to
execute) SQL.
However, I couldn't find a good way to preserve the reference and still
have the clause be consistently optimized out. The closest I got was
compiling empty IN to `and_(expr, literal(0))` and empty NOT IN to
`or_(expr, literal(1))` --- this does get optimized out in the case where
`expr` is a single column. Unfortunately, this is a syntax error in the
case of a "composite IN" ("tuple" IN, or "row constructor" IN), e.g.,
`(my_table.col_a, my_table.col_b) IN ((1, 2), (3, 4))`.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.