Fix searching with uppercase booleans
AND and OR caused a syntax error while 'and' and 'or' worked. The debugging method at the bottom of __init__.py is intentional, at least until there's real testing for this. Change-Id: Ib5a5d7b47d64204f6dda36513dea8249d3bbce4e
This commit is contained in:
parent
a8422949ac
commit
b10441866a
@ -62,9 +62,18 @@ class SearchCompiler(object):
|
||||
if __name__ == '__main__':
|
||||
class Dummy(object):
|
||||
pass
|
||||
query = 'status:open AND topic:enable_swift'
|
||||
lexer = tokenizer.SearchTokenizer()
|
||||
lexer.input(query)
|
||||
while True:
|
||||
token = lexer.token()
|
||||
if not token:
|
||||
break
|
||||
print token
|
||||
|
||||
app = Dummy()
|
||||
app.config = Dummy()
|
||||
app.config.username = 'bob'
|
||||
search = SearchCompiler(app)
|
||||
x = search.parse('owner:self')
|
||||
x = search.parse(query)
|
||||
print x
|
||||
|
@ -47,12 +47,12 @@ def SearchParser():
|
||||
def p_boolean_expr(p):
|
||||
'''boolean_expr : expression AND expression
|
||||
| expression OR expression'''
|
||||
if p[2] == 'and':
|
||||
if p[2].lower() == 'and':
|
||||
p[0] = and_(p[1], p[3])
|
||||
elif p[2] == 'or':
|
||||
elif p[2].lower() == 'or':
|
||||
p[0] = or_(p[1], p[3])
|
||||
else:
|
||||
raise SyntaxError()
|
||||
raise gertty.search.SearchSyntaxError("Boolean %s not recognized" % p[2])
|
||||
|
||||
def p_negative_expr(p):
|
||||
'''negative_expr : NOT expression
|
||||
|
Loading…
x
Reference in New Issue
Block a user