geopython / pygeofilter

pygeofilter is a pure Python parser implementation of OGC filtering standards
MIT License
83 stars 32 forks source link

Are cql2-json operators mandatory lowercase? #45

Open LeoBreebaart opened 2 years ago

LeoBreebaart commented 2 years ago

The cql2_json parser fails with a ValueError if I try to pass it an operator in uppercase, e.g. "op": "or", "args": [...] is fine, but "op": "OR", "args": [...] fails. And indeed, in _cql2json/parser.py we find an explicit test if op in ("and", "or"): (ditto for all the other operators, of course).

What is the reasoning behind this? cql2_text is case-insensitive w.r.t. operators (on account of presumably deliberate condition "OR"i etc. specifications in the Lark grammar), but if I consult the CQL2 JSON standard spec I just see things like orExpression = booleanExpression "OR" booleanExpression; which to me would indicate either case insensitivity (haven't been able to quickly find out what the default is for BNF literals) or in fact mandatory uppercase...

philvarner commented 2 years ago

cql2-json is case sensitive. The JSON Schema has this explicitly:

 "op": {
          "type": "string",
          "enum": [ "and", "or" ]
        },

which means only those those two strings may be used.

My understanding of BNF literals is that they are always considered to be insensitive (someone who seemed to understand this told me then when I raised what I thought was an issue with RFC 3339 datetime parsing).