issue 594 fixed, != in grid query

This commit is contained in:
Massimo Di Pierro
2012-01-16 22:29:53 -06:00
parent 0f43651e09
commit 76699b6b8e
3 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
Version 1.99.4 (2012-01-16 22:03:22) stable
Version 1.99.4 (2012-01-16 22:29:44) stable
+9 -7
View File
@@ -5059,7 +5059,7 @@ def smart_query(fields,text):
for a,b in [('&','and'),
('|','or'),
('~','not'),
('==','=='),
('==','='),
('<','<'),
('>','>'),
('<=','<='),
@@ -5067,7 +5067,7 @@ def smart_query(fields,text):
('<>','!='),
('=<','<='),
('=>','>='),
('=','=='),
('=','='),
(' less or equal than ','<='),
(' greater or equal than ','>='),
(' equal or less than ','<='),
@@ -5078,18 +5078,19 @@ def smart_query(fields,text):
(' equal or greater ','>='),
(' not equal to ','!='),
(' not equal ','!='),
(' equal to ','=='),
(' equal ','=='),
(' equal to ','='),
(' equal ','='),
(' equals ','!='),
(' less than ','<'),
(' greater than ','>'),
(' starts with ','startswith'),
(' ends with ','endswith'),
(' is ','==')]:
(' is ','=')]:
if a[0]==' ':
text = text.replace(' is'+a,' %s ' % b)
text = text.replace(a,' %s ' % b)
text = re.sub('\s+',' ',text).lower()
text = re.sub('(?P<a>[\<\>\!\=])\s+(?P<b>[\<\>\!\=])','\g<a>\g<b>',text)
query = field = neg = op = logic = None
for item in text.split():
if field is None:
@@ -5110,12 +5111,13 @@ def smart_query(fields,text):
value = constants[item[1:]]
else:
value = item
if op == '==': op = 'like'
if op == '==': new_query = field==value
if op == '=': op = 'like'
if op == '=': new_query = field==value
elif op == '<': new_query = field<value
elif op == '>': new_query = field>value
elif op == '<=': new_query = field<=value
elif op == '>=': new_query = field>=value
elif op == '!=': new_query = field!=value
elif field.type in ('text','string'):
if op == 'contains': new_query = field.contains(value)
elif op == 'like': new_query = field.like(value)
+1 -1
View File
@@ -1292,7 +1292,7 @@ class SQLFORM(FORM):
@staticmethod
def build_query(fields,keywords):
key = keywords.strip()
if key and not ' ' in key:
if key and not ' ' in key and not '"' in key and not "'" in key:
SEARCHABLE_TYPES = ('string','text','list:string')
parts = [field.contains(key) for field in fields if field.type in SEARCHABLE_TYPES]
else: