diff --git a/tailbone/newgrids/alchemy.py b/tailbone/newgrids/alchemy.py index 8c358917..a3d2a9f0 100644 --- a/tailbone/newgrids/alchemy.py +++ b/tailbone/newgrids/alchemy.py @@ -102,7 +102,8 @@ class AlchemyGrid(Grid): elif isinstance(column.type, sa.Integer): factory = filters.AlchemyNumericFilter elif isinstance(column.type, sa.Boolean): - factory = filters.AlchemyBooleanFilter + # TODO: check column for nullable here? + factory = filters.AlchemyNullableBooleanFilter elif isinstance(column.type, sa.Date): factory = filters.AlchemyDateFilter elif isinstance(column.type, sa.DateTime): diff --git a/tailbone/newgrids/filters.py b/tailbone/newgrids/filters.py index 32c3778e..be51c63e 100644 --- a/tailbone/newgrids/filters.py +++ b/tailbone/newgrids/filters.py @@ -336,7 +336,7 @@ class AlchemyBooleanFilter(AlchemyGridFilter): """ 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): """ @@ -353,6 +353,13 @@ class AlchemyBooleanFilter(AlchemyGridFilter): 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): """ Date filter for SQLAlchemy.