server/search: make searches case insensitive

This commit is contained in:
rr- 2016-05-11 18:52:49 +02:00
parent 82d32ba1fb
commit 6179f016ae
2 changed files with 3 additions and 2 deletions

View File

@ -62,11 +62,11 @@ class BaseSearchConfig(object):
Decorate SQLAlchemy filter on given column using supplied criterion.
'''
if isinstance(criterion, criteria.PlainSearchCriterion):
expr = column.like(transformer(criterion.value))
expr = column.ilike(transformer(criterion.value))
elif isinstance(criterion, criteria.ArraySearchCriterion):
expr = sqlalchemy.sql.false()
for value in criterion.values:
expr = expr | column.like(transformer(value))
expr = expr | column.ilike(transformer(value))
elif isinstance(criterion, criteria.RangedSearchCriterion):
raise szurubooru.errors.SearchError(
'Composite token %r is invalid in this context.' % (criterion,))

View File

@ -22,6 +22,7 @@ def verify_unpaged(executor):
('t1', ['t1']),
('t2', ['t2']),
('t1,t2', ['t1', 't2']),
('T1,T2', ['t1', 't2']),
])
def test_filter_anonymous(verify_unpaged, tag_factory, input, expected_tag_names):
db.session.add(tag_factory(names=['t1']))