diff --git a/pygeofilter/parsers/ecql/grammar.lark b/pygeofilter/parsers/ecql/grammar.lark index 75611d9..bb1314a 100644 --- a/pygeofilter/parsers/ecql/grammar.lark +++ b/pygeofilter/parsers/ecql/grammar.lark @@ -109,7 +109,7 @@ period: DATETIME "/" DATETIME envelope: "ENVELOPE" "(" number number number number ")" -BOOLEAN: ( "TRUE" | "FALSE" ) +BOOLEAN.2: ( "TRUE"i | "FALSE"i ) DOUBLE_QUOTED: "\"" /.*?/ "\"" SINGLE_QUOTED: "'" /.*?/ "'" diff --git a/pygeofilter/parsers/ecql/parser.py b/pygeofilter/parsers/ecql/parser.py index 2a1c4f7..b3de9ae 100644 --- a/pygeofilter/parsers/ecql/parser.py +++ b/pygeofilter/parsers/ecql/parser.py @@ -181,7 +181,7 @@ def FLOAT(self, value): return float(value) def BOOLEAN(self, value): - return value == "TRUE" + return value.lower() == "true" def DOUBLE_QUOTED(self, token): return token[1:-1] diff --git a/tests/parsers/ecql/test_parser.py b/tests/parsers/ecql/test_parser.py index 9fa7fd9..5266b23 100644 --- a/tests/parsers/ecql/test_parser.py +++ b/tests/parsers/ecql/test_parser.py @@ -41,6 +41,7 @@ def test_namespace_attribute_eq_literal(): "A", ) + def test_prefixed_attribute_eq_literal(): result = parse("properties.ns:attr = 'A'") assert result == ast.Equal( @@ -48,6 +49,7 @@ def test_prefixed_attribute_eq_literal(): "A", ) + def test_attribute_eq_literal(): result = parse("attr = 'A'") assert result == ast.Equal( @@ -595,3 +597,35 @@ def test_function_attr_string_arg(): ], ), ) + + +def test_attribute_eq_true_uppercase(): + result = parse("attr = TRUE") + assert result == ast.Equal( + ast.Attribute("attr"), + True, + ) + + +def test_attribute_eq_true_lowercase(): + result = parse("attr = true") + assert result == ast.Equal( + ast.Attribute("attr"), + True, + ) + + +def test_attribute_eq_false_uppercase(): + result = parse("attr = FALSE") + assert result == ast.Equal( + ast.Attribute("attr"), + False, + ) + + +def test_attribute_eq_false_lowercase(): + result = parse("attr = false") + assert result == ast.Equal( + ast.Attribute("attr"), + False, + )