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
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
* Specify `minimum_input_length` for ajax widget
* 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
-----
......
def parse_like_term(term):
"""
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
= = exact
:param term:
Search term
"""
case_insensitive = term.startswith('*')
if case_insensitive:
case_sensitive = term.startswith('*')
if case_sensitive:
term = term[1:]
# apply operators
if term.startswith('^'):
......@@ -23,6 +23,6 @@ def parse_like_term(term):
else:
oper = 'contains'
# add case insensitive flag
if case_insensitive:
if not case_sensitive:
oper = 'i' + oper
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