Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
derfenix committed Jul 6, 2017
1 parent 7fa41b7 commit b34105c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions django_sp/helpers/rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def _convert(self, value: Any):


class CombinedSearchFilter(StringFilter):
"""Search within many fields"""
value_templates = {
'start': '%{}',
'end': '{}%',
Expand All @@ -203,9 +204,20 @@ class CombinedSearchFilter(StringFilter):

# noinspection PyMissingConstructor
def __init__(self, map_to: Tuple, max_length: Optional[int] = 255, strict_search: Optional[bool] = False,
case_sensitive: Optional[bool] = True, wildcard_place: Optional[str] = 'both'):
case_sensitive: Optional[bool] = True, wildcard_place: Optional[str] = 'both',
strict_fields=None):
"""
:param map_to: List of fields for search
:param max_length: maximum value length
:param strict_search: Search with equal (=) instead of ILIKE
:param case_sensitive: Use LIKE instead of ILIKE
:param wildcard_place: Where the ? mark should be placed
:param strict_fields: Fields, that should not use LIKE/LIKE. Integer fields must be listed here, as well as
other fields that have no LIKE/ILIKE operators
"""
assert wildcard_place in ('start', 'end', 'both')
self.search_fields = map_to
self.strict_fields = strict_fields if strict_fields is not None else []
self.wildcard_place = wildcard_place
self.max_length = max_length
self.strict_search = strict_search
Expand All @@ -220,7 +232,7 @@ def filter(self, name: str, condition: str, value: str) -> str:
"""
conditions = []

if self.strict_search:
if self.strict_search or name in self.strict_fields:
operator = '='
else:
value_template = self.value_templates[self.wildcard_place]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='django_stored_procedures',
version='0.3.5',
version='0.3.6',
keywords=['django', 'stored procedures', 'database'],
packages=find_packages(),
url='https://github.com/derfenix/django_stored_procedures/',
Expand Down

0 comments on commit b34105c

Please sign in to comment.