Treat filter by "contains X Y" as "contains X and contains Y".
This commit is contained in:
parent
c9b01f6061
commit
920f0144c2
|
@ -287,7 +287,8 @@ class AlchemyStringFilter(AlchemyGridFilter):
|
||||||
"""
|
"""
|
||||||
if value is None or value == '':
|
if value is None or value == '':
|
||||||
return query
|
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):
|
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.
|
# include things which are nothing at all, in our result set.
|
||||||
return query.filter(sa.or_(
|
return query.filter(sa.or_(
|
||||||
self.column == None,
|
self.column == None,
|
||||||
~self.column.ilike('%{0}%'.format(value)),
|
sa.and_(
|
||||||
|
*[~self.column.ilike('%{0}%'.format(v)) for v in value.split()]),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue