Permalink
Browse files

add a test and a fix for queries with OR and AND (in caps)

  • Loading branch information...
1 parent 5b4c1c2 commit c825a644cf758b52f267ad2cd8ea63700c85da22 @jmoiron committed Feb 24, 2011
Showing with 6 additions and 0 deletions.
  1. +2 −0 iris/query/lexer.py
  2. +2 −0 iris/query/parser.py
  3. +2 −0 tests/parser.py
View
@@ -15,6 +15,8 @@ class LexerToken(object):
def __init__(self, type, value):
self.type = type.lower()
self.value = value[0] if isinstance(value, list) else value
+ if self.type == 'operator':
+ self.value = self.value.lower()
def is_field(self): return self.type == 'field'
def is_ws(self): return self.type == 'whitespace'
@@ -19,6 +19,8 @@ class IrisToken(object):
def __init__(self, type, value):
self.type = type.lower()
self.value = value[0] if isinstance(value, list) else value
+ if self.type in ('or', 'and'):
+ self.value = self.value.lower()
def is_field(self): return self.type == 'field'
def is_ws(self): return self.type == 'whitespace'
View
@@ -208,5 +208,7 @@ def test_and_queries(self):
def test_or_queries(self):
find = q.FindStatement('find 10 (iso) where iso > 200 or tags in ("italy")')
self.assertStatement(find, 10, 1, {'$or' : [{'iso':{'$gt':200}}, {'tags': {'$in':['italy']}}]})
+ find = q.FindStatement('find 10 (iso) where iso > 200 OR tags in ("italy")')
+ self.assertStatement(find, 10, 1, {'$or' : [{'iso':{'$gt':200}}, {'tags': {'$in':['italy']}}]})

0 comments on commit c825a64

Please sign in to comment.