Commit b7dba99d authored by Jérome Perrin's avatar Jérome Perrin

Make sure we can search SQL keywords.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13416 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0c8d7997
...@@ -824,6 +824,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -824,6 +824,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.tic() self.tic()
self.assertNotEquals([], self.getCatalogTool().searchResults( self.assertNotEquals([], self.getCatalogTool().searchResults(
portal_type='Person', title=u'A Person')) portal_type='Person', title=u'A Person'))
def test_23_DeleteObjectRaiseErrorWhenQueryFail(self, quiet=quiet, run=run_all_test): def test_23_DeleteObjectRaiseErrorWhenQueryFail(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -1617,3 +1618,31 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1617,3 +1618,31 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
ctool.countResults(title='Object Title', ctool.countResults(title='Object Title',
local_roles='Assignee;Auditor')[0][0]) local_roles='Assignee;Auditor')[0][0])
def test_51_SearchWithKeyWords(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
message = 'Test searching with SQL keywords'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
person_module = self.getPersonModule()
and_ = person_module.newContent(portal_type='Person', title='AND')
or_ = person_module.newContent(portal_type='Person', title='OR')
like_ = person_module.newContent(portal_type='Person', title='LIKE')
select_ = person_module.newContent(portal_type='Person', title='SELECT')
get_transaction().commit()
self.tic()
ctool = self.getCatalogTool()
self.assertEquals([and_], [x.getObject() for x in
ctool(portal_type='Person', title='AND')])
self.assertEquals([or_], [x.getObject() for x in
ctool(portal_type='Person', title='OR')])
self.assertEquals([like_], [x.getObject() for x in
ctool(portal_type='Person', title='LIKE')])
self.assertEquals([select_], [x.getObject() for x in
ctool(portal_type='Person', title='SELECT')])
...@@ -286,7 +286,7 @@ class Query(QueryMixin): ...@@ -286,7 +286,7 @@ class Query(QueryMixin):
# Refer to _listGlobalActions DCWorkflow patch # Refer to _listGlobalActions DCWorkflow patch
# for example of use # for example of use
if isinstance(value, basestring): if isinstance(value, basestring):
value = value.split('OR') value = value.split(' OR ')
value = map(lambda x:x.strip(), value) value = map(lambda x:x.strip(), value)
value_list = value value_list = value
if isSimpleType(value) or isinstance(value, DateTime): if isSimpleType(value) or isinstance(value, DateTime):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment