From 75287624e2c724ec9962a9df07791201d0e8bb52 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 3 Mar 2009 14:44:25 +0000
Subject: [PATCH] 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
---
 product/ZSQLCatalog/SearchKey/DefaultKey.py |  4 ++++
 product/ZSQLCatalog/tests/testSQLCatalog.py | 10 +++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/product/ZSQLCatalog/SearchKey/DefaultKey.py b/product/ZSQLCatalog/SearchKey/DefaultKey.py
index f1bc2d19c4..2c8299efe4 100644
--- a/product/ZSQLCatalog/SearchKey/DefaultKey.py
+++ b/product/ZSQLCatalog/SearchKey/DefaultKey.py
@@ -29,6 +29,7 @@
 ##############################################################################
 
 from SearchKey import SearchKey
+from Products.ZSQLCatalog.SearchText import parse
 from Products.ZSQLCatalog.Interface.ISearchKey import ISearchKey
 from Interface.Verify import verifyClass
 
@@ -41,6 +42,9 @@ class DefaultKey(SearchKey):
   default_comparison_operator = '='
   get_operator_from_value = True
 
+  def parseSearchText(self, value):
+    return parse(value)
+
   def _guessComparisonOperator(self, value):
     if isinstance(value, basestring) and '%' in value:
       operator = 'like'
diff --git a/product/ZSQLCatalog/tests/testSQLCatalog.py b/product/ZSQLCatalog/tests/testSQLCatalog.py
index 8fbcb2f0df..c22386dff4 100644
--- a/product/ZSQLCatalog/tests/testSQLCatalog.py
+++ b/product/ZSQLCatalog/tests/testSQLCatalog.py
@@ -184,16 +184,20 @@ class TestSQLCatalog(unittest.TestCase):
                    {column: '!=a'})
       self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a b'), operator='and'),
                    {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'})
-      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'})
       self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='>a >b'), operator='and'),
                    {column: '">a >b"'})
       self.catalog(ReferenceQuery(ReferenceQuery(operator='>', default='>a >b'), operator='and'),
                    {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'})
+      self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a OR b'), operator='and'),
+                   {column: '"a OR b"'})
       self.catalog(ReferenceQuery(ReferenceQuery(operator='<', default='path'), operator='and'),
                    {column: {'query': 'path', 'range': 'max'}})
       self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'),
-- 
2.30.9