Commit d7c5ff08 authored by PJ Janse van Rensburg's avatar PJ Janse van Rensburg

Merge branch 'case-insensitive-mongo'

parents 1f3d1b72 5444acf2
...@@ -8,6 +8,7 @@ next release ...@@ -8,6 +8,7 @@ next release
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration * Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
* Specify `minimum_input_length` for ajax widget * Specify `minimum_input_length` for ajax widget
* SQLAlchemy fix that lets you use inline model forms where models have multiple primary keys * SQLAlchemy fix that lets you use inline model forms where models have multiple primary keys
* MongoEngine: when searching/filtering the input is now regarded as case-insensitive by default
1.5.2 1.5.2
----- -----
......
def parse_like_term(term): def parse_like_term(term):
""" """
Parse search term into (operation, term) tuple. Recognizes operators Parse search term into (operation, term) tuple. Recognizes operators
in the beginning of the search term. in the beginning of the search term. Case insensitive is the default.
* = case insensitive (can precede other operators) * = case sensitive (can precede other operators)
^ = starts with ^ = starts with
= = exact = = exact
:param term: :param term:
Search term Search term
""" """
case_insensitive = term.startswith('*') case_sensitive = term.startswith('*')
if case_insensitive: if case_sensitive:
term = term[1:] term = term[1:]
# apply operators # apply operators
if term.startswith('^'): if term.startswith('^'):
...@@ -23,6 +23,6 @@ def parse_like_term(term): ...@@ -23,6 +23,6 @@ def parse_like_term(term):
else: else:
oper = 'contains' oper = 'contains'
# add case insensitive flag # add case insensitive flag
if case_insensitive: if not case_sensitive:
oper = 'i' + oper oper = 'i' + oper
return oper, term return oper, term
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment