diff --git a/product/ZSQLCatalog/SearchKey/DefaultKey.py b/product/ZSQLCatalog/SearchKey/DefaultKey.py index c3903df033e5c4618458be70e0a7875b531d03cf..fbc99c2984bfef9920b1a9a4cdbffb971f5394a3 100644 --- a/product/ZSQLCatalog/SearchKey/DefaultKey.py +++ b/product/ZSQLCatalog/SearchKey/DefaultKey.py @@ -83,7 +83,7 @@ class DefaultKey(SearchKey): t_LESSTHAN = r'<' def t_WORD(self, t): - r'[\x7F-\xFF\w\d\/\-~!@#$%^&*()_+\n][\x7F-\xFF\w\d\/\-~!@#$%^&*()_+\n]*' + r'[\x7F-\xFF\w\d\/\.\-~!@#$%^&*()_+\n][\x7F-\xFF\w\d\/\.\-~!@#$%^&*()_+\n]*' #r'[\x7F-\xFF\w\d\/%][\x7F-\xFF\w\d\/%]*' # WORD may contain arbitrary letters and numbers without white space # WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD) @@ -92,7 +92,7 @@ class DefaultKey(SearchKey): return t def t_WORDSET(self, t): - r'"[\x7F-\xFF\w\d\s\/~!@#$%^&*()_+][\x7F-\xFF\w\d\s\/~!@#$%^&*()_+]*"' + r'"[\x7F-\xFF\w\d\s\/\.~!@#$%^&*()_+][\x7F-\xFF\w\d\s\/\.~!@#$%^&*()_+]*"' #r'"[\x7F-\xFF\w\d\s/%][\x7F-\xFF\w\d\s/%]*"' # WORDSET is a combination of WORDs separated by white space # and starting/ending with " diff --git a/product/ZSQLCatalog/SearchKey/FullTextKey.py b/product/ZSQLCatalog/SearchKey/FullTextKey.py index d60218685bb6954190ea7c23db179545cced16a1..d013fdf7cdf30790267713c4ab883c04dd60d7ce 100644 --- a/product/ZSQLCatalog/SearchKey/FullTextKey.py +++ b/product/ZSQLCatalog/SearchKey/FullTextKey.py @@ -58,7 +58,7 @@ class FullTextKey(SearchKey): t_DOUBLEQUOTE = r'(\")' def t_WORD(self, t): - r'[\x7F-\xFF\w\d\/!@#$%^&_][\x7F-\xFF\w\d\/!@#$%^&_]*' + r'[\x7F-\xFF\w\d\/\.!@#$%^&_][\x7F-\xFF\w\d\/\.!@#$%^&_]*' #r'[\x7F-\xFF\w\d][\x7F-\xFF\w\d]*' # WORD may contain arbitrary letters and numbers without white space word_value = t.value diff --git a/product/ZSQLCatalog/SearchKey/KeyWordKey.py b/product/ZSQLCatalog/SearchKey/KeyWordKey.py index dc523621c8f221f7039564b9627f4b1000828225..935d03fc71db50b64349f69e03e075c2a1dc37e5 100644 --- a/product/ZSQLCatalog/SearchKey/KeyWordKey.py +++ b/product/ZSQLCatalog/SearchKey/KeyWordKey.py @@ -92,7 +92,7 @@ class KeyWordKey(SearchKey): t_LESSTHAN = r'<' def t_EXPLICITEQUALLITYWORD(self, t): - r'=[\x7F-\xFF\w\d\/~!@#$^&*()_+][\x7F-\xFF\w\d\/~!@#$^&*()_+]*' + r'=[\x7F-\xFF\w\d\/\.~!@#$^&*()_+][\x7F-\xFF\w\d\/\.~!@#$^&*()_+]*' # EXPLICITEQUALLITYWORD may contain arbitrary letters and numbers without white space # EXPLICITEQUALLITYWORD must contain '=' at the beginning value = t.value.strip() @@ -101,7 +101,7 @@ class KeyWordKey(SearchKey): return t def t_KEYWORD(self, t): - r'%?[\x7F-\xFF\w\d/~!@#$%^&*()_+][\x7F-\xFF\w\d/~!@#$%^&*()_+]*%?' + r'%?[\x7F-\xFF\w\d/\.~!@#$%^&*()_+][\x7F-\xFF\w\d/\.~!@#$%^&*()_+]*%?' # KEYWORD may starts(1) and may ends (2) with '%' but always must either #1 or #2 # be true. It may contains arbitrary letters, numbers and white space value = t.value.strip() @@ -111,7 +111,7 @@ class KeyWordKey(SearchKey): return t def t_WORD(self, t): - r'[\x7F-\xFF\w\d\/~!@#$^&*()_+][\x7F-\xFF\w\d\/~!@#$^&*()_+]*' + r'[\x7F-\xFF\w\d\/\.~!@#$^&*()_+][\x7F-\xFF\w\d\/\.~!@#$^&*()_+]*' # WORD may contain arbitrary letters and numbers without white space # WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD) value = t.value.strip() @@ -119,7 +119,7 @@ class KeyWordKey(SearchKey): return t def t_WORDSET(self, t): - r'=?"[\x7F-\xFF\w\d\s\/~!@#$%^&*()_+][\x7F-\xFF\w\d\s\/~!@#$%^&*()_+]*"' + r'=?"[\x7F-\xFF\w\d\s\/\.~!@#$%^&*()_+][\x7F-\xFF\w\d\s\/\.~!@#$%^&*()_+]*"' # WORDSET is a combination of WORDs separated by white space # and starting/ending with " (optionally with '=') value = t.value.replace('"', '') diff --git a/product/ZSQLCatalog/tests/testSearchKeys.py b/product/ZSQLCatalog/tests/testSearchKeys.py index c5048f2ccb742dc6a502fe3262e1202b108e9be9..59c113b6920e4256953aaab0cac8c5091d653d1d 100644 --- a/product/ZSQLCatalog/tests/testSearchKeys.py +++ b/product/ZSQLCatalog/tests/testSearchKeys.py @@ -84,6 +84,7 @@ size/Child/34""" self.compare(DefaultKey, 'S\xc3\xa9bastien or !="Doe John1" and Doe', ('WORD', 'OR', 'NOT', 'WORDSET', 'AND', 'WORD',)) + self.compare(DefaultKey, '.', ('WORD',)) def test_03KeyWordKey(self, quiet=quiet, run=run_all_test): """ Check lexer for KeyWordKey.""" @@ -105,6 +106,7 @@ size/Child/34""" self.compare(KeyWordKey, '=John% and >="JOHN John"', ('EXPLICITEQUALLITYWORD', 'KEYWORD', 'AND', 'GREATERTHANEQUAL', 'WORDSET',)) + self.compare(KeyWordKey, '.', ('WORD',)) def test_04DateTimeKey(self, quiet=quiet, run=run_all_test): """ Check lexer for DateTimeKey.""" @@ -125,6 +127,7 @@ size/Child/34""" ('WORD', 'WORD',)) self.compare(FullTextKey, '+John -Doe', ('PLUS', 'WORD', 'MINUS', 'WORD',)) + self.compare(FullTextKey, '.', ('WORD',)) def test_06ScriptableKey(self, quiet=quiet, run=run_all_test): """ Check lexer for ScriptableKey.""" @@ -199,6 +202,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase): '%John and !=Doe%', "((((title = '%John') AND (title != 'Doe%'))))", []) + # special chars + self.compare(DefaultKey, + 'title', + '.', + "((((title = '.'))))", + []) def test_02KeyWordKey(self, quiet=quiet, run=run_all_test): """ Check DefaultKey query generation""" @@ -228,6 +237,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase): '%John Doe% or =Doe John', "((((title LIKE '%John Doe%'))) OR (((title = 'Doe John'))))", []) + # special chars + self.compare(KeyWordKey, + 'title', + '.', + "((((title LIKE '%.%'))))", + []) def test_03DateTimeKey(self, quiet=quiet, run=run_all_test): """ Check DefaultKey query generation""" @@ -349,6 +364,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase): '1ab521ty', "delivery.stock = '1ab521ty'", []) + # special chars + self.compare(RawKey, + 'delivery.stock', + '.', + "delivery.stock = '.'", + []) def test_06FullTextKey(self, quiet=quiet, run=run_all_test): """ Check FullTextKey query generation""" @@ -359,6 +380,14 @@ class TestSearchKeyQuery(ERP5TypeTestCase): "MATCH full_text.SearchableText AGAINST ('john' )", ["MATCH full_text.SearchableText AGAINST ('john' ) AS full_text_SearchableText_relevance", "MATCH full_text.SearchableText AGAINST ('john' ) AS SearchableText_relevance"]) + + # special chars + self.compare(FullTextKey, + 'full_text.SearchableText', + '.', + "MATCH full_text.SearchableText AGAINST ('.' )", + ["MATCH full_text.SearchableText AGAINST ('.' ) AS full_text_SearchableText_relevance", + "MATCH full_text.SearchableText AGAINST ('.' ) AS SearchableText_relevance"]) def test_07ScriptableKey(self, quiet=quiet, run=run_all_test): """ Check ScriptableKey query generation"""