Skip to content

Commit

Permalink
Merge pull request #108 from antoine-de/ecql_boolean
Browse files Browse the repository at this point in the history
Handle boolean in ecql like cql_text
  • Loading branch information
constantinius authored Dec 30, 2024
2 parents cbf900c + 885ea29 commit 464880f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pygeofilter/parsers/ecql/grammar.lark
Original file line number Diff line number Diff line change
Expand Up @@ -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: "'" /.*?/ "'"
Expand Down
2 changes: 1 addition & 1 deletion pygeofilter/parsers/ecql/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
32 changes: 32 additions & 0 deletions tests/parsers/ecql/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,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,
)

0 comments on commit 464880f

Please sign in to comment.