diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index 044d2302..676480b6 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -416,7 +416,7 @@ class Grid(object): elif isinstance(column.type, sa.Numeric): factory = gridfilters.AlchemyNumericFilter elif isinstance(column.type, sa.Integer): - factory = gridfilters.AlchemyNumericFilter + factory = gridfilters.AlchemyIntegerFilter elif isinstance(column.type, sa.Boolean): # TODO: check column for nullable here? factory = gridfilters.AlchemyNullableBooleanFilter diff --git a/tailbone/grids/filters.py b/tailbone/grids/filters.py index a3431ef6..7d355300 100644 --- a/tailbone/grids/filters.py +++ b/tailbone/grids/filters.py @@ -460,6 +460,18 @@ class AlchemyNumericFilter(AlchemyGridFilter): return super(AlchemyNumericFilter, self).filter_less_equal(query, value) +class AlchemyIntegerFilter(AlchemyNumericFilter): + """ + Integer filter for SQLAlchemy. + """ + + def value_invalid(self, value): + if value: + if not value.isdigit(): + return True + return False + + class AlchemyBooleanFilter(AlchemyGridFilter): """ Boolean filter for SQLAlchemy.