Skip to content

Commit 464880f

Browse files
Merge pull request #108 from antoine-de/ecql_boolean
Handle boolean in ecql like cql_text
2 parents cbf900c + 885ea29 commit 464880f

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

pygeofilter/parsers/ecql/grammar.lark

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ period: DATETIME "/" DATETIME
109109

110110
envelope: "ENVELOPE" "(" number number number number ")"
111111

112-
BOOLEAN: ( "TRUE" | "FALSE" )
112+
BOOLEAN.2: ( "TRUE"i | "FALSE"i )
113113

114114
DOUBLE_QUOTED: "\"" /.*?/ "\""
115115
SINGLE_QUOTED: "'" /.*?/ "'"

pygeofilter/parsers/ecql/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def FLOAT(self, value):
181181
return float(value)
182182

183183
def BOOLEAN(self, value):
184-
return value == "TRUE"
184+
return value.lower() == "true"
185185

186186
def DOUBLE_QUOTED(self, token):
187187
return token[1:-1]

tests/parsers/ecql/test_parser.py

+32
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,35 @@ def test_function_attr_string_arg():
597597
],
598598
),
599599
)
600+
601+
602+
def test_attribute_eq_true_uppercase():
603+
result = parse("attr = TRUE")
604+
assert result == ast.Equal(
605+
ast.Attribute("attr"),
606+
True,
607+
)
608+
609+
610+
def test_attribute_eq_true_lowercase():
611+
result = parse("attr = true")
612+
assert result == ast.Equal(
613+
ast.Attribute("attr"),
614+
True,
615+
)
616+
617+
618+
def test_attribute_eq_false_uppercase():
619+
result = parse("attr = FALSE")
620+
assert result == ast.Equal(
621+
ast.Attribute("attr"),
622+
False,
623+
)
624+
625+
626+
def test_attribute_eq_false_lowercase():
627+
result = parse("attr = false")
628+
assert result == ast.Equal(
629+
ast.Attribute("attr"),
630+
False,
631+
)

0 commit comments

Comments
 (0)