Fix filtering on boolean columns, broken with SQLAlchemy 1.2 upgrade

SQLAlchemy 1.2 does not allow comparing string values to boolean
columns. This caused errors like:

    sqlalchemy.exc.StatementError: (builtins.TypeError) Not a boolean value: 'true'

For more details see http://docs.sqlalchemy.org/en/latest/changelog/migration_12.html#boolean-datatype-now-enforces-strict-true-false-none-values
This commit is contained in:
Marti Raudsepp
2018-04-02 18:33:51 +03:00
parent b4b9a913b3
commit 8e2b2123f1
7 changed files with 30 additions and 14 deletions

View File

@ -175,3 +175,9 @@ def windowed_query(q, column, windowsize):
column, windowsize):
for row in q.filter(whereclause).order_by(column):
yield row
def truthiness(s):
"""If input string resembles something truthy then return True, else False."""
return s.lower() in ('true', 'yes', 'on', 't', '1')