From 76699b6b8e615768728f1cf94c2a691c46b07ff3 Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Mon, 16 Jan 2012 22:29:53 -0600 Subject: [PATCH] issue 594 fixed, != in grid query --- VERSION | 2 +- gluon/dal.py | 16 +++++++++------- gluon/sqlhtml.py | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 92241d6a..87af14ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.4 (2012-01-16 22:03:22) stable +Version 1.99.4 (2012-01-16 22:29:44) stable diff --git a/gluon/dal.py b/gluon/dal.py index 23266af4..2cf7f578 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -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[\<\>\!\=])\s+(?P[\<\>\!\=])','\g\g',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': 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) diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 6be176fe..f76d096d 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -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: