geopython / geopython/pygeofilter
Invalid cql-json `and` expression is parsed into "wrong" ast
- Dominant language
- Python
- Stars
- 90
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
I cannot find any description of how pygeofilter is supposed to behave when it meets invalid filters. The issue is written assuming that pygeofilter should fail when parsing invalid filters.
Example 1 where pygeofilter silently ignores invalid `and` expression:
```
>>> import pygeofilter.ast
>>> from pygeofilter.parsers.cql_json import parse as parse_json
>>>
>>> cql_json = { "intersects": [ { "property": "geometry" }, { "type": "Point", "coordinates": [ 10.4064, 55.3951 ] } ], "and": [ {"eq": [ { "property": "direction" }, "east" ] } ] }
>>> print(pygeofilter.ast.get_repr(parse_json(cql_json)))
INTERSECTS(ATTRIBUTE geometry, Geometry(geometry={'type': 'Point', 'coordinates': [10.4064, 55.3951]}))
```
Example 2 where pygeofilter parses invalid `and` into a simple comparison:
```
>>> import pygeofilter.ast
>>> from pygeofilter.parsers.cql_json import parse as parse_json
>>>
>>> cql_json = { "and": [ {"eq": [ { "property": "direction" }, "east" ] } ] }
>>> print(pygeofilter.ast.get_repr(parse_json(cql_json)))
ATTRIBUTE direction = 'east'
```
Needless to say it would be a better user experience if both these examples would fail with some meaningful message.
Contributor guide
Assessment
This issue has not been assessed yet.