Add "is false or null" verb for boolean grid filters

This commit is contained in:
Lance Edgar 2019-10-09 10:55:13 -05:00
parent c812519931
commit 700813fa57

View file

@ -138,6 +138,7 @@ class GridFilter(object):
'is_not_null': "is not null", 'is_not_null': "is not null",
'is_true': "is true", 'is_true': "is true",
'is_false': "is false", 'is_false': "is false",
'is_false_null': "is false or null",
'contains': "contains", 'contains': "contains",
'does_not_contain': "does not contain", 'does_not_contain': "does not contain",
'is_me': "is me", 'is_me': "is me",
@ -145,7 +146,7 @@ class GridFilter(object):
} }
valueless_verbs = ['is_any', 'is_null', 'is_not_null', 'is_true', 'is_false', valueless_verbs = ['is_any', 'is_null', 'is_not_null', 'is_true', 'is_false',
'is_me', 'is_not_me'] 'is_false_null', 'is_me', 'is_not_me']
value_renderer_factory = DefaultValueRenderer value_renderer_factory = DefaultValueRenderer
data_type = 'string' # default, but will be set from value renderer data_type = 'string' # default, but will be set from value renderer
@ -548,7 +549,16 @@ class AlchemyNullableBooleanFilter(AlchemyBooleanFilter):
""" """
Boolean filter for SQLAlchemy which is NULL-aware. Boolean filter for SQLAlchemy which is NULL-aware.
""" """
default_verbs = ['is_true', 'is_false', 'is_null', 'is_not_null', 'is_any'] default_verbs = ['is_true', 'is_false', 'is_false_null',
'is_null', 'is_not_null', 'is_any']
def filter_is_false_null(self, query, value):
"""
Filter data with an "is false or null" query. Note that this filter
does not use the value for anything.
"""
return query.filter(sa.or_(self.column == False,
self.column == None))
class AlchemyDateFilter(AlchemyGridFilter): class AlchemyDateFilter(AlchemyGridFilter):