support for in and not in smart_query
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.2.1 (2012-12-02 08:26:35) stable
|
Version 2.2.1 (2012-12-03 08:15:18) stable
|
||||||
|
|||||||
+6
-2
@@ -6566,11 +6566,13 @@ def smart_query(fields,text):
|
|||||||
(' 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'),
|
||||||
|
(' not in ' , 'notbelongs'),
|
||||||
|
(' in ' , 'belongs'),
|
||||||
(' is ','=')]:
|
(' is ','=')]:
|
||||||
if a[0]==' ':
|
if a[0]==' ':
|
||||||
text = text.replace(' is'+a,' %s ' % b)
|
text = text.replace(' is'+a,' %s ' % b)
|
||||||
@@ -6605,6 +6607,8 @@ def smart_query(fields,text):
|
|||||||
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 == 'belongs': new_query = field.belongs(value.split(','))
|
||||||
|
elif op == 'notbelongs': new_query = ~field.belongs(value.split(','))
|
||||||
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)
|
||||||
@@ -7175,7 +7179,7 @@ def index():
|
|||||||
table._actual = True
|
table._actual = True
|
||||||
self[tablename] = table
|
self[tablename] = table
|
||||||
# must follow above line to handle self references
|
# must follow above line to handle self references
|
||||||
table._create_references()
|
table._create_references()
|
||||||
|
|
||||||
migrate = self._migrate_enabled and args_get('migrate',self._migrate)
|
migrate = self._migrate_enabled and args_get('migrate',self._migrate)
|
||||||
if migrate and not self._uri in (None,'None') \
|
if migrate and not self._uri in (None,'None') \
|
||||||
|
|||||||
+7
-7
@@ -1561,15 +1561,15 @@ class SQLFORM(FORM):
|
|||||||
def search_menu(fields, search_options=None):
|
def search_menu(fields, search_options=None):
|
||||||
T = current.T
|
T = current.T
|
||||||
search_options = search_options or {
|
search_options = search_options or {
|
||||||
'string': ['=', '!=', '<', '>', '<=', '>=', 'starts with', 'contains'],
|
'string': ['=', '!=', '<', '>', '<=', '>=', 'starts with', 'contains', 'in', 'not in'],
|
||||||
'text': ['=', '!=', '<', '>', '<=', '>=', 'starts with', 'contains'],
|
'text': ['=', '!=', '<', '>', '<=', '>=', 'starts with', 'contains', 'in', 'not in'],
|
||||||
'date': ['=', '!=', '<', '>', '<=', '>='],
|
'date': ['=', '!=', '<', '>', '<=', '>='],
|
||||||
'time': ['=', '!=', '<', '>', '<=', '>='],
|
'time': ['=', '!=', '<', '>', '<=', '>='],
|
||||||
'datetime': ['=', '!=', '<', '>', '<=', '>='],
|
'datetime': ['=', '!=', '<', '>', '<=', '>='],
|
||||||
'integer': ['=', '!=', '<', '>', '<=', '>='],
|
'integer': ['=', '!=', '<', '>', '<=', '>=', 'in', 'not in'],
|
||||||
'double': ['=', '!=', '<', '>', '<=', '>='],
|
'double': ['=', '!=', '<', '>', '<=', '>='],
|
||||||
'id': ['=', '!=', '<', '>', '<=', '>='],
|
'id': ['=', '!=', '<', '>', '<=', '>=', 'in', 'not in'],
|
||||||
'reference': ['=', '!=', '<', '>', '<=', '>='],
|
'reference': ['=', '!=', '<', '>', '<=', '>=', 'in', 'not in'],
|
||||||
'boolean': ['=', '!=']}
|
'boolean': ['=', '!=']}
|
||||||
if fields[0]._db._adapter.dbengine == 'google:datastore':
|
if fields[0]._db._adapter.dbengine == 'google:datastore':
|
||||||
search_options['string'] = ['=', '!=', '<', '>', '<=', '>=']
|
search_options['string'] = ['=', '!=', '<', '>', '<=', '>=']
|
||||||
@@ -2268,7 +2268,7 @@ class SQLFORM(FORM):
|
|||||||
if callable(rid): # can this ever be callable?
|
if callable(rid): # can this ever be callable?
|
||||||
rid = rid(row)
|
rid = rid(row)
|
||||||
tr = TR(*trcols, **dict(
|
tr = TR(*trcols, **dict(
|
||||||
_id=rid,
|
_id=rid,
|
||||||
_class='%s %s' % (classtr, 'with_id')))
|
_class='%s %s' % (classtr, 'with_id')))
|
||||||
else:
|
else:
|
||||||
tr = TR(*trcols, **dict(_class=classtr))
|
tr = TR(*trcols, **dict(_class=classtr))
|
||||||
@@ -2343,7 +2343,7 @@ class SQLFORM(FORM):
|
|||||||
table: pagination, search, view, edit, delete,
|
table: pagination, search, view, edit, delete,
|
||||||
children, parent, etc.
|
children, parent, etc.
|
||||||
|
|
||||||
constraints is a dict {'table',query} that limits which
|
constraints is a dict {'table':query} that limits which
|
||||||
records can be accessible
|
records can be accessible
|
||||||
links is a dict like
|
links is a dict like
|
||||||
{'tablename':[lambda row: A(....), ...]}
|
{'tablename':[lambda row: A(....), ...]}
|
||||||
|
|||||||
Reference in New Issue
Block a user