I have a boolean field in the mysql db table.
# table model
class TestCase(Base):
__tablename__ = 'test_cases'
...
obsoleted = Column('obsoleted', Boolean)
To get the count of all the non-obsoleted test cases, that can be done simply like this:
caseNum = session.query(TestCase).filter(TestCase.obsoleted == False).count()
print(caseNum)
That works fine, but the flake8 report the following warning:
E712: Comparison to False should be "if cond is False:" or "if not cond:"
Okay, I think that make sense. So change my code to this:
caseNum = session.query(TestCase).filter(TestCase.obsoleted is False).count()
or
caseNum = session.query(TestCase).filter(not TestCase.obsoleted).count()
But neither of them can work. The result is always 0. I think the filter clause doesn't support the operator "is" or "is not". Will someone can tell me how to handle this situation. I don't want to disable the flake.