I have a query which tries to get list of users for a particular set of 
events which joins with the user table to check if the user is not marked 
for a particular flag "dnd" (flag column could have a null value too). The 
query goes something like this:

query = session.query(Event.uid).filter(Event.event.in_(event_list)).\
        join(User, and_((User.id == Event.uid), \
        or_(User.flag == None, User.flag != "dnd")))

It raises an Argument error exception

ArgumentError("Only '=', '!=', 'is_()', 'isnot()' operators can
be used with None/True/False",)

I've tried other possibilities/suggestions (listed below) but still get the 
same error:

   - using # noqa
   - checking "User.Flag is None"
   - checking "User.Flag.is_(None)"

In other places, when I'm checking only with the User table without a join, 
it seems to work. For eg:

User.query.filter(User.flag == None, User.flag != "dnd").all()


DB being used is postgresql.

How do I check for NULL value within this join?

SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper


To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to