issue 594 fixed, != in grid query
This commit is contained in:
@@ -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
@@ -5059,7 +5059,7 @@ def smart_query(fields,text):
|
|||||||
for a,b in [('&','and'),
|
for a,b in [('&','and'),
|
||||||
('|','or'),
|
('|','or'),
|
||||||
('~','not'),
|
('~','not'),
|
||||||
('==','=='),
|
('==','='),
|
||||||
('<','<'),
|
('<','<'),
|
||||||
('>','>'),
|
('>','>'),
|
||||||
('<=','<='),
|
('<=','<='),
|
||||||
@@ -5067,7 +5067,7 @@ def smart_query(fields,text):
|
|||||||
('<>','!='),
|
('<>','!='),
|
||||||
('=<','<='),
|
('=<','<='),
|
||||||
('=>','>='),
|
('=>','>='),
|
||||||
('=','=='),
|
('=','='),
|
||||||
(' less or equal than ','<='),
|
(' less or equal than ','<='),
|
||||||
(' greater or equal than ','>='),
|
(' greater or equal than ','>='),
|
||||||
(' equal or less than ','<='),
|
(' equal or less than ','<='),
|
||||||
@@ -5078,18 +5078,19 @@ def smart_query(fields,text):
|
|||||||
(' equal or greater ','>='),
|
(' equal or greater ','>='),
|
||||||
(' not equal to ','!='),
|
(' not equal to ','!='),
|
||||||
(' not equal ','!='),
|
(' not equal ','!='),
|
||||||
(' equal to ','=='),
|
(' equal to ','='),
|
||||||
(' equal ','=='),
|
(' equal ','='),
|
||||||
(' equals ','!='),
|
(' equals ','!='),
|
||||||
(' less than ','<'),
|
(' less than ','<'),
|
||||||
(' greater than ','>'),
|
(' greater than ','>'),
|
||||||
(' starts with ','startswith'),
|
(' starts with ','startswith'),
|
||||||
(' ends with ','endswith'),
|
(' ends with ','endswith'),
|
||||||
(' is ','==')]:
|
(' is ','=')]:
|
||||||
if a[0]==' ':
|
if a[0]==' ':
|
||||||
text = text.replace(' is'+a,' %s ' % b)
|
text = text.replace(' is'+a,' %s ' % b)
|
||||||
text = text.replace(a,' %s ' % b)
|
text = text.replace(a,' %s ' % b)
|
||||||
text = re.sub('\s+',' ',text).lower()
|
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
|
query = field = neg = op = logic = None
|
||||||
for item in text.split():
|
for item in text.split():
|
||||||
if field is None:
|
if field is None:
|
||||||
@@ -5110,12 +5111,13 @@ def smart_query(fields,text):
|
|||||||
value = constants[item[1:]]
|
value = constants[item[1:]]
|
||||||
else:
|
else:
|
||||||
value = item
|
value = item
|
||||||
if op == '==': op = 'like'
|
if op == '=': op = 'like'
|
||||||
if op == '==': new_query = field==value
|
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 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'):
|
elif field.type in ('text','string'):
|
||||||
if op == 'contains': new_query = field.contains(value)
|
if op == 'contains': new_query = field.contains(value)
|
||||||
elif op == 'like': new_query = field.like(value)
|
elif op == 'like': new_query = field.like(value)
|
||||||
|
|||||||
+1
-1
@@ -1292,7 +1292,7 @@ class SQLFORM(FORM):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def build_query(fields,keywords):
|
def build_query(fields,keywords):
|
||||||
key = keywords.strip()
|
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')
|
SEARCHABLE_TYPES = ('string','text','list:string')
|
||||||
parts = [field.contains(key) for field in fields if field.type in SEARCHABLE_TYPES]
|
parts = [field.contains(key) for field in fields if field.type in SEARCHABLE_TYPES]
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user