server/search: rename search criterion

This commit is contained in:
rr- 2016-04-17 18:15:59 +02:00
parent c957befbd0
commit 08271caf32
3 changed files with 5 additions and 5 deletions

View File

@ -31,7 +31,7 @@ class BaseSearchConfig(object):
''' '''
Decorate SQLAlchemy filter on given column using supplied criterion. Decorate SQLAlchemy filter on given column using supplied criterion.
''' '''
if isinstance(criterion, criteria.StringSearchCriterion): if isinstance(criterion, criteria.PlainSearchCriterion):
expr = column == int(criterion.value) expr = column == int(criterion.value)
elif isinstance(criterion, criteria.ArraySearchCriterion): elif isinstance(criterion, criteria.ArraySearchCriterion):
expr = column.in_(int(value) for value in criterion.values) expr = column.in_(int(value) for value in criterion.values)
@ -55,7 +55,7 @@ class BaseSearchConfig(object):
Decorate SQLAlchemy filter on given column using supplied criterion. Decorate SQLAlchemy filter on given column using supplied criterion.
Parse potential wildcards inside the criterion. Parse potential wildcards inside the criterion.
''' '''
if isinstance(criterion, criteria.StringSearchCriterion): if isinstance(criterion, criteria.PlainSearchCriterion):
expr = column.like(criterion.value.replace('*', '%')) expr = column.like(criterion.value.replace('*', '%'))
elif isinstance(criterion, criteria.ArraySearchCriterion): elif isinstance(criterion, criteria.ArraySearchCriterion):
expr = sqlalchemy.sql.false() expr = sqlalchemy.sql.false()
@ -81,7 +81,7 @@ class BaseSearchConfig(object):
Decorate SQLAlchemy filter on given column using supplied criterion. Decorate SQLAlchemy filter on given column using supplied criterion.
Parse the datetime inside the criterion. Parse the datetime inside the criterion.
''' '''
if isinstance(criterion, criteria.StringSearchCriterion): if isinstance(criterion, criteria.PlainSearchCriterion):
min_date, max_date = misc.parse_time_range(criterion.value) min_date, max_date = misc.parse_time_range(criterion.value)
expr = column.between(min_date, max_date) expr = column.between(min_date, max_date)
elif isinstance(criterion, criteria.ArraySearchCriterion): elif isinstance(criterion, criteria.ArraySearchCriterion):

View File

@ -12,7 +12,7 @@ class RangedSearchCriterion(_BaseSearchCriterion):
self.min_value = min_value self.min_value = min_value
self.max_value = max_value self.max_value = max_value
class StringSearchCriterion(_BaseSearchCriterion): class PlainSearchCriterion(_BaseSearchCriterion):
def __init__(self, original_text, negated, value): def __init__(self, original_text, negated, value):
super().__init__(original_text, negated) super().__init__(original_text, negated)
self.value = value self.value = value

View File

@ -126,4 +126,4 @@ class SearchExecutor(object):
if ',' in value: if ',' in value:
return criteria.ArraySearchCriterion( return criteria.ArraySearchCriterion(
value, negated, value.split(',')) value, negated, value.split(','))
return criteria.StringSearchCriterion(value, negated, value) return criteria.PlainSearchCriterion(value, negated, value)