Skip to content

Commit

Permalink
Merge pull request #93 from Ariana-B/improve-attribute-name-parsing
Browse files Browse the repository at this point in the history
Support prefixed attribute names in cql2-text and ecql parsing
  • Loading branch information
constantinius authored Jul 8, 2024
2 parents 23f172c + 5318c6b commit dbe4e9e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pygeofilter/parsers/cql2_text/grammar.lark
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
| expression "LIKE"i SINGLE_QUOTED -> like
| expression "IN"i "(" expression ( "," expression )* ")" -> in_
| expression "IS"i "NULL"i -> null
| expression "IS"i "NOT"i "NULL"i -> not_null
| "INCLUDE"i -> include
| "EXCLUDE"i -> exclude
| spatial_predicate
Expand Down Expand Up @@ -137,7 +138,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 dbe4e9e

Please sign in to comment.