Commit 60f94952 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Julien Muchembled

ZSQLCatalog: add support for NULL value in SearchText parsing

parent cb73785f
...@@ -264,7 +264,9 @@ class AdvancedSearchTextParser(lexer): ...@@ -264,7 +264,9 @@ class AdvancedSearchTextParser(lexer):
def p_value(self, p): def p_value(self, p):
'''value : OPERATOR string '''value : OPERATOR string
| string''' | OPERATOR NULL
| string
| NULL'''
if len(p) == 2: if len(p) == 2:
p[0] = ValueNode(p[1]) p[0] = ValueNode(p[1])
else: else:
......
from SearchTextParser import parse, isAdvancedSearchText from SearchTextParser import parse, isAdvancedSearchText
def dequote(value): def dequote(value):
assert isinstance(value, basestring), value if isinstance(value, basestring) and len(value) >= 2 and \
if len(value) >= 2 and value[0] == value[-1] == '"' and value[-2] != '\\': value[0] == value[-1] == '"' and value[-2] != '\\':
escaped = False escaped = False
value_list = [] value_list = []
append = value_list.append append = value_list.append
......
...@@ -82,7 +82,9 @@ class lexer(object): ...@@ -82,7 +82,9 @@ class lexer(object):
'WORD', 'WORD',
'OPERATOR', 'OPERATOR',
'LEFT_PARENTHESE', 'LEFT_PARENTHESE',
'RIGHT_PARENTHESE') 'RIGHT_PARENTHESE',
'NULL',
)
t_ignore = ' ' t_ignore = ' '
...@@ -123,6 +125,11 @@ class lexer(object): ...@@ -123,6 +125,11 @@ class lexer(object):
r'[^><= :\(\)"][^ :\(\)"]*' r'[^><= :\(\)"][^ :\(\)"]*'
return t return t
def t_NULL(self, t):
r'NULL'
t.value = None
return t
def parse(self, *args, **kw): def parse(self, *args, **kw):
kw['lexer'] = self kw['lexer'] = self
return self.parser.parse(*args, **kw) return self.parser.parse(*args, **kw)
......
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