[Erp5-report] r45521 romain - in /erp5/trunk/products/ZSQLCatalog: SearchKey/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Apr 15 16:23:38 CEST 2011


Author: romain
Date: Fri Apr 15 16:23:38 2011
New Revision: 45521

URL: http://svn.erp5.org?rev=45521&view=rev
Log:
improve FULLTEXT_BOOLEAN_DETECTOR, i.e. '*a' is not a boolean search, but 'a*' is.

Modified:
    erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py
    erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py

Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py?rev=45521&r1=45520&r2=45521&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py [utf8] Fri Apr 15 16:23:38 2011
@@ -36,7 +36,7 @@ from zope.interface.verify import verify
 from Products.ZSQLCatalog.SQLCatalog import profiler_decorator
 import re
 
-FULLTEXT_BOOLEAN_DETECTOR = re.compile(r'.*(^|\s)[\+\-<>\(\)\~\*]')
+FULLTEXT_BOOLEAN_DETECTOR = re.compile(r'.*((^|\s)[\+\-<>\(\~]|[\*\)](\s|$))')
 
 class FullTextKey(SearchKey):
   """

Modified: erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py?rev=45521&r1=45520&r2=45521&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py [utf8] Fri Apr 15 16:23:38 2011
@@ -539,11 +539,29 @@ class TestSQLCatalog(unittest.TestCase):
       Fulltext searches must switch automatically to boolean mode if boolean
       operators are found in search value.
     """
+    self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean',
+                                fulltext=MatchList(['a*'])), operator='and'),
+                 {'fulltext': 'a*'})
+
+    self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean',
+                                fulltext=MatchList(['a* b'])), operator='and'),
+                 {'fulltext': 'a* b'})
+
+    self.catalog(ReferenceQuery(ReferenceQuery(operator='match', fulltext='*a'),
+                                operator='and'),
+                 {'fulltext': '*a'})
+
+    self.catalog(ReferenceQuery(ReferenceQuery(operator='match', fulltext='a'),
+                                operator='and'),
+                 {'fulltext': 'a'})
+
     self.catalog(ReferenceQuery(ReferenceQuery(operator='match', fulltext='a+b'), operator='and'),
                  {'fulltext': 'a+b'})
+
     self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean',
       fulltext=MatchList(['a +b', '+b a'])), operator='and'),
                  {'fulltext': 'a +b'}, check_search_text=False)
+
     self.catalog(ReferenceQuery(ReferenceQuery(
         ReferenceQuery(operator='=', uid='foo'),
         ReferenceQuery(operator='match_boolean',



More information about the Erp5-report mailing list