Tweak default factory for boolean grid filters

This commit is contained in:
Lance Edgar 2016-11-10 23:13:21 -06:00
parent 7afd9c87df
commit 1f9a27a7ae
2 changed files with 10 additions and 2 deletions

View file

@ -102,7 +102,8 @@ class AlchemyGrid(Grid):
elif isinstance(column.type, sa.Integer): elif isinstance(column.type, sa.Integer):
factory = filters.AlchemyNumericFilter factory = filters.AlchemyNumericFilter
elif isinstance(column.type, sa.Boolean): elif isinstance(column.type, sa.Boolean):
factory = filters.AlchemyBooleanFilter # TODO: check column for nullable here?
factory = filters.AlchemyNullableBooleanFilter
elif isinstance(column.type, sa.Date): elif isinstance(column.type, sa.Date):
factory = filters.AlchemyDateFilter factory = filters.AlchemyDateFilter
elif isinstance(column.type, sa.DateTime): elif isinstance(column.type, sa.DateTime):

View file

@ -336,7 +336,7 @@ class AlchemyBooleanFilter(AlchemyGridFilter):
""" """
Boolean filter for SQLAlchemy. Boolean filter for SQLAlchemy.
""" """
default_verbs = ['is_true', 'is_false', 'is_null', 'is_not_null', 'is_any'] default_verbs = ['is_true', 'is_false', 'is_any']
def filter_is_true(self, query, value): def filter_is_true(self, query, value):
""" """
@ -353,6 +353,13 @@ class AlchemyBooleanFilter(AlchemyGridFilter):
return query.filter(self.column == False) return query.filter(self.column == False)
class AlchemyNullableBooleanFilter(AlchemyBooleanFilter):
"""
Boolean filter for SQLAlchemy which is NULL-aware.
"""
default_verbs = ['is_true', 'is_false', 'is_null', 'is_not_null', 'is_any']
class AlchemyDateFilter(AlchemyGridFilter): class AlchemyDateFilter(AlchemyGridFilter):
""" """
Date filter for SQLAlchemy. Date filter for SQLAlchemy.