diff --git a/tailbone/newgrids/filters.py b/tailbone/newgrids/filters.py index 3b03ddbc..fa5b71a7 100644 --- a/tailbone/newgrids/filters.py +++ b/tailbone/newgrids/filters.py @@ -287,7 +287,8 @@ class AlchemyStringFilter(AlchemyGridFilter): """ if value is None or value == '': return query - return query.filter(self.column.ilike('%{0}%'.format(value))) + return query.filter(sa.and_( + *[self.column.ilike('%{0}%'.format(v)) for v in value.split()])) def filter_does_not_contain(self, query, value): """ @@ -300,7 +301,8 @@ class AlchemyStringFilter(AlchemyGridFilter): # include things which are nothing at all, in our result set. return query.filter(sa.or_( self.column == None, - ~self.column.ilike('%{0}%'.format(value)), + sa.and_( + *[~self.column.ilike('%{0}%'.format(v)) for v in value.split()]), ))