allow unsorted multiword query in grid search
This commit is contained in:
+9
-7
@@ -1756,10 +1756,16 @@ class SQLFORM(FORM):
|
|||||||
keywords = keywords[0]
|
keywords = keywords[0]
|
||||||
request.vars.keywords = keywords
|
request.vars.keywords = keywords
|
||||||
key = keywords.strip()
|
key = keywords.strip()
|
||||||
if key and ' ' not in key and not '"' in key and not "'" in key:
|
if not '"' in key:
|
||||||
SEARCHABLE_TYPES = ('string', 'text', 'list:string')
|
SEARCHABLE_TYPES = ('string', 'text', 'list:string')
|
||||||
parts = [field.contains(
|
sfields = [field for field in fields if field.type in SEARCHABLE_TYPES]
|
||||||
key) for field in fields if field.type in SEARCHABLE_TYPES]
|
if settings.global_settings.web2py_runtime_gae:
|
||||||
|
return reduce(lambda a,b: a|b, [field.contains(key) for field in sfields])
|
||||||
|
else:
|
||||||
|
return reduce(lambda a,b:a&b,[
|
||||||
|
reduce(lambda a,b: a|b, [
|
||||||
|
field.contains(k) for field in sfields]
|
||||||
|
) for k in key.split()])
|
||||||
|
|
||||||
# from https://groups.google.com/forum/#!topic/web2py/hKe6lI25Bv4
|
# from https://groups.google.com/forum/#!topic/web2py/hKe6lI25Bv4
|
||||||
# needs testing...
|
# needs testing...
|
||||||
@@ -1773,10 +1779,6 @@ class SQLFORM(FORM):
|
|||||||
# filters.append(reduce(lambda a, b: (a & b), all_words_filters))
|
# filters.append(reduce(lambda a, b: (a & b), all_words_filters))
|
||||||
#parts = filters
|
#parts = filters
|
||||||
|
|
||||||
else:
|
|
||||||
parts = None
|
|
||||||
if parts:
|
|
||||||
return reduce(lambda a, b: a | b, parts)
|
|
||||||
else:
|
else:
|
||||||
return smart_query(fields, key)
|
return smart_query(fields, key)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user