Commit 9ee72682 authored by Jérome Perrin's avatar Jérome Perrin

include "." character in the definition of WORD token


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19262 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 06d3d058
...@@ -83,7 +83,7 @@ class DefaultKey(SearchKey): ...@@ -83,7 +83,7 @@ class DefaultKey(SearchKey):
t_LESSTHAN = r'<' t_LESSTHAN = r'<'
def t_WORD(self, t): 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\/%]*' #r'[\x7F-\xFF\w\d\/%][\x7F-\xFF\w\d\/%]*'
# WORD may contain arbitrary letters and numbers without white space # WORD may contain arbitrary letters and numbers without white space
# WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD) # WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD)
...@@ -92,7 +92,7 @@ class DefaultKey(SearchKey): ...@@ -92,7 +92,7 @@ class DefaultKey(SearchKey):
return t return t
def t_WORDSET(self, 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/%]*"' #r'"[\x7F-\xFF\w\d\s/%][\x7F-\xFF\w\d\s/%]*"'
# WORDSET is a combination of WORDs separated by white space # WORDSET is a combination of WORDs separated by white space
# and starting/ending with " # and starting/ending with "
......
...@@ -58,7 +58,7 @@ class FullTextKey(SearchKey): ...@@ -58,7 +58,7 @@ class FullTextKey(SearchKey):
t_DOUBLEQUOTE = r'(\")' t_DOUBLEQUOTE = r'(\")'
def t_WORD(self, t): 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]*' #r'[\x7F-\xFF\w\d][\x7F-\xFF\w\d]*'
# WORD may contain arbitrary letters and numbers without white space # WORD may contain arbitrary letters and numbers without white space
word_value = t.value word_value = t.value
......
...@@ -92,7 +92,7 @@ class KeyWordKey(SearchKey): ...@@ -92,7 +92,7 @@ class KeyWordKey(SearchKey):
t_LESSTHAN = r'<' t_LESSTHAN = r'<'
def t_EXPLICITEQUALLITYWORD(self, t): 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 may contain arbitrary letters and numbers without white space
# EXPLICITEQUALLITYWORD must contain '=' at the beginning # EXPLICITEQUALLITYWORD must contain '=' at the beginning
value = t.value.strip() value = t.value.strip()
...@@ -101,7 +101,7 @@ class KeyWordKey(SearchKey): ...@@ -101,7 +101,7 @@ class KeyWordKey(SearchKey):
return t return t
def t_KEYWORD(self, 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 # 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 # be true. It may contains arbitrary letters, numbers and white space
value = t.value.strip() value = t.value.strip()
...@@ -111,7 +111,7 @@ class KeyWordKey(SearchKey): ...@@ -111,7 +111,7 @@ class KeyWordKey(SearchKey):
return t return t
def t_WORD(self, 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 arbitrary letters and numbers without white space
# WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD) # WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD)
value = t.value.strip() value = t.value.strip()
...@@ -119,7 +119,7 @@ class KeyWordKey(SearchKey): ...@@ -119,7 +119,7 @@ class KeyWordKey(SearchKey):
return t return t
def t_WORDSET(self, 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 # WORDSET is a combination of WORDs separated by white space
# and starting/ending with " (optionally with '=') # and starting/ending with " (optionally with '=')
value = t.value.replace('"', '') value = t.value.replace('"', '')
......
...@@ -84,6 +84,7 @@ size/Child/34""" ...@@ -84,6 +84,7 @@ size/Child/34"""
self.compare(DefaultKey, self.compare(DefaultKey,
'S\xc3\xa9bastien or !="Doe John1" and Doe', 'S\xc3\xa9bastien or !="Doe John1" and Doe',
('WORD', 'OR', 'NOT', 'WORDSET', 'AND', 'WORD',)) ('WORD', 'OR', 'NOT', 'WORDSET', 'AND', 'WORD',))
self.compare(DefaultKey, '.', ('WORD',))
def test_03KeyWordKey(self, quiet=quiet, run=run_all_test): def test_03KeyWordKey(self, quiet=quiet, run=run_all_test):
""" Check lexer for KeyWordKey.""" """ Check lexer for KeyWordKey."""
...@@ -105,6 +106,7 @@ size/Child/34""" ...@@ -105,6 +106,7 @@ size/Child/34"""
self.compare(KeyWordKey, '=John% and >="JOHN John"', self.compare(KeyWordKey, '=John% and >="JOHN John"',
('EXPLICITEQUALLITYWORD', 'KEYWORD', 'AND', ('EXPLICITEQUALLITYWORD', 'KEYWORD', 'AND',
'GREATERTHANEQUAL', 'WORDSET',)) 'GREATERTHANEQUAL', 'WORDSET',))
self.compare(KeyWordKey, '.', ('WORD',))
def test_04DateTimeKey(self, quiet=quiet, run=run_all_test): def test_04DateTimeKey(self, quiet=quiet, run=run_all_test):
""" Check lexer for DateTimeKey.""" """ Check lexer for DateTimeKey."""
...@@ -125,6 +127,7 @@ size/Child/34""" ...@@ -125,6 +127,7 @@ size/Child/34"""
('WORD', 'WORD',)) ('WORD', 'WORD',))
self.compare(FullTextKey, '+John -Doe', self.compare(FullTextKey, '+John -Doe',
('PLUS', 'WORD', 'MINUS', 'WORD',)) ('PLUS', 'WORD', 'MINUS', 'WORD',))
self.compare(FullTextKey, '.', ('WORD',))
def test_06ScriptableKey(self, quiet=quiet, run=run_all_test): def test_06ScriptableKey(self, quiet=quiet, run=run_all_test):
""" Check lexer for ScriptableKey.""" """ Check lexer for ScriptableKey."""
...@@ -199,6 +202,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase): ...@@ -199,6 +202,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase):
'%John and !=Doe%', '%John and !=Doe%',
"((((title = '%John') AND (title != 'Doe%'))))", "((((title = '%John') AND (title != 'Doe%'))))",
[]) [])
# special chars
self.compare(DefaultKey,
'title',
'.',
"((((title = '.'))))",
[])
def test_02KeyWordKey(self, quiet=quiet, run=run_all_test): def test_02KeyWordKey(self, quiet=quiet, run=run_all_test):
""" Check DefaultKey query generation""" """ Check DefaultKey query generation"""
...@@ -228,6 +237,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase): ...@@ -228,6 +237,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase):
'%John Doe% or =Doe John', '%John Doe% or =Doe John',
"((((title LIKE '%John Doe%'))) OR (((title = '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): def test_03DateTimeKey(self, quiet=quiet, run=run_all_test):
""" Check DefaultKey query generation""" """ Check DefaultKey query generation"""
...@@ -349,6 +364,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase): ...@@ -349,6 +364,12 @@ class TestSearchKeyQuery(ERP5TypeTestCase):
'1ab521ty', '1ab521ty',
"delivery.stock = '1ab521ty'", "delivery.stock = '1ab521ty'",
[]) [])
# special chars
self.compare(RawKey,
'delivery.stock',
'.',
"delivery.stock = '.'",
[])
def test_06FullTextKey(self, quiet=quiet, run=run_all_test): def test_06FullTextKey(self, quiet=quiet, run=run_all_test):
""" Check FullTextKey query generation""" """ Check FullTextKey query generation"""
...@@ -359,6 +380,14 @@ class TestSearchKeyQuery(ERP5TypeTestCase): ...@@ -359,6 +380,14 @@ class TestSearchKeyQuery(ERP5TypeTestCase):
"MATCH full_text.SearchableText AGAINST ('john' )", "MATCH full_text.SearchableText AGAINST ('john' )",
["MATCH full_text.SearchableText AGAINST ('john' ) AS full_text_SearchableText_relevance", ["MATCH full_text.SearchableText AGAINST ('john' ) AS full_text_SearchableText_relevance",
"MATCH full_text.SearchableText AGAINST ('john' ) AS 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): def test_07ScriptableKey(self, quiet=quiet, run=run_all_test):
""" Check ScriptableKey query generation""" """ Check ScriptableKey query generation"""
......
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