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):
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 "
......
......@@ -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
......
......@@ -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('"', '')
......
......@@ -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"""
......
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