Commit 75287624 authored by Vincent Pelletier's avatar Vincent Pelletier

Enable parsing in DefaultKey. Update test to describe that behaviour (which is...

Enable parsing in DefaultKey. Update test to describe that behaviour (which is more consistent with previous behaviour).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25833 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 47dbf2ed
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
############################################################################## ##############################################################################
from SearchKey import SearchKey from SearchKey import SearchKey
from Products.ZSQLCatalog.SearchText import parse
from Products.ZSQLCatalog.Interface.ISearchKey import ISearchKey from Products.ZSQLCatalog.Interface.ISearchKey import ISearchKey
from Interface.Verify import verifyClass from Interface.Verify import verifyClass
...@@ -41,6 +42,9 @@ class DefaultKey(SearchKey): ...@@ -41,6 +42,9 @@ class DefaultKey(SearchKey):
default_comparison_operator = '=' default_comparison_operator = '='
get_operator_from_value = True get_operator_from_value = True
def parseSearchText(self, value):
return parse(value)
def _guessComparisonOperator(self, value): def _guessComparisonOperator(self, value):
if isinstance(value, basestring) and '%' in value: if isinstance(value, basestring) and '%' in value:
operator = 'like' operator = 'like'
......
...@@ -184,16 +184,20 @@ class TestSQLCatalog(unittest.TestCase): ...@@ -184,16 +184,20 @@ class TestSQLCatalog(unittest.TestCase):
{column: '!=a'}) {column: '!=a'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a b'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a b'), operator='and'),
{column: 'a b'}) {column: 'a b'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a >b'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='=', default='a'), ReferenceQuery(operator='>', default='b'), operator='or'), operator='and'),
{column: 'a >b'}) {column: 'a >b'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='>', default='a >b'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a > b'), operator='and'),
{column: 'a > b'})
self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='>', default='a'), ReferenceQuery(operator='>', default='b'), operator='or'), operator='and'),
{column: '>a >b'}) {column: '>a >b'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='>a >b'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='>a >b'), operator='and'),
{column: '">a >b"'}) {column: '">a >b"'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='>', default='>a >b'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='>', default='>a >b'), operator='and'),
{column: '>">a >b"'}) {column: '>">a >b"'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a OR b'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'),
{column: 'a OR b'}) {column: 'a OR b'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a OR b'), operator='and'),
{column: '"a OR b"'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='<', default='path'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='<', default='path'), operator='and'),
{column: {'query': 'path', 'range': 'max'}}) {column: {'query': 'path', 'range': 'max'}})
self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'),
......
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