Skip to content

Commit

Permalink
Improve cql2-text and ecql parsing to all for prefixed attribute names
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariana Barzinpour committed Apr 5, 2024
1 parent 06254fc commit 122a5a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pygeofilter/parsers/cql2_text/grammar.lark
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ DATETIME: /[0-9]{4}-?[0-1][0-9]-?[0-3][0-9][T ][0-2][0-9]:?[0-5][0-9]:?[0-5][0-9



attribute: /[a-zA-Z][a-zA-Z_:0-9]+/
attribute: /[a-zA-Z][a-zA-Z_:0-9.]+/
| DOUBLE_QUOTED


Expand Down
2 changes: 1 addition & 1 deletion pygeofilter/parsers/ecql/grammar.lark
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ BOOLEAN: ( "TRUE" | "FALSE" )
DOUBLE_QUOTED: "\"" /.*?/ "\""
SINGLE_QUOTED: "'" /.*?/ "'"

QUALIFIED_NAME: NAME ":" NAME
QUALIFIED_NAME: (NAME ("." | ":"))+ NAME

%import .wkt.ewkt_geometry
%import .iso8601.DATETIME
Expand Down
6 changes: 6 additions & 0 deletions tests/parsers/ecql/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def test_namespace_attribute_eq_literal():
"A",
)

def test_prefixed_attribute_eq_literal():
result = parse("properties.ns:attr = 'A'")
assert result == ast.Equal(
ast.Attribute("properties.ns:attr"),
"A",
)

def test_attribute_eq_literal():
result = parse("attr = 'A'")
Expand Down

0 comments on commit 122a5a6

Please sign in to comment.