Tons of choices now! I was just getting errors from statement.compile on old code, and started to put together a bug report. Then I remembered "not null" comparisons were coming, and checked the changelog and ran my testcase against a few historical tags.
I probably had an edge case, because i used variables to sub None/True/False into a column operator (to get around the previous versions not having is/isnot operators) On Wednesday, October 1, 2014 6:06:20 PM UTC-4, Michael Bayer wrote: > > > you have either “x != None” or “x != null()” or “x.isnot(None)”, or > “x.isnot(null()))” > > a lot of choices! > > > > On Oct 1, 2014, at 5:51 PM, Jonathan Vanasco <jvan...@gmail.com > <javascript:>> wrote: > > I'm just posting this to the group for search equity-- > > Until recently (2012, via this commit > https://bitbucket.org/zzzeek/sqlalchemy/issue/2544), the way recommended > several times in this group and stackoverflow to generate "IS NOT NULL" was > to use a column opreation: > > sq = sess.query(A.id.label('id')).filter(A.id.op('IS NOT')(None)) > > However, that will cause a sqlalchemy.exc.CompileError when > print/compiling a statement with "literal binds" > > # this will raise an error > print str(sq.statement.compile(dialect=postgresql.dialect(), > compile_kwargs={"literal_binds": True})) > > To get around that issue, these forms will all compile correctly: > > # 0.7.9 and later > sq = sess.query(A.id.label('id')).filter(A.id != None) > > # 0.7.8 and earlier > sq = sess.query(A.id.label('id')).filter(A.id.op('IS > NOT')(sqlalchemy.sql.expression.null())) > > > -- > 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 sqlalchemy+...@googlegroups.com <javascript:>. > To post to this group, send email to sqlal...@googlegroups.com > <javascript:>. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > > > -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.