pygeofilter icon indicating copy to clipboard operation
pygeofilter copied to clipboard

to_cql2 incorrectly formats isNull args

Open Ariana-B opened this issue 10 months ago • 2 comments

According to the cql2 spec, the NULL predicate should look like this in cql2-json:

{
      "op": "isNull",
      "args": [ { "property": "geometry" } ]
}

However, if using to_cql2 to generate the json, args is not a list:

>>> from pygeofilter.parsers.ecql import parse as parse_ecql
>>> from pygeofilter.backends.cql2_json import to_cql2
>>> to_cql2(parse_ecql("geometry IS NULL"))
'{"op": "isNull", "args": {"property": "geometry"}}'

Ariana-B avatar Mar 28 '24 02:03 Ariana-B

@Ariana-B

Hmm, maybe this has changed again, but now the spec clearly depicts is as a single input. Even the example shows it so:

{ "not": { "isNull" : { "property": "geometry" } } }

This is the schema:

     "isNullPredicate": {
         "type": "object",
         "required": [ "isNull" ],
         "properties": {
            "isNull": {
               "$ref": "#/$defs/scalarExpression"
            }
         }
      },

So it looks like it again should be different than our solutions.

constantinius avatar Jul 08 '24 12:07 constantinius

@constantinius

It's worth noting that the most recent version of the CQL2 spec has the isNull predicate as an array:

{
  "op": "not",
  "args": [
    {
      "op": "isNull",
      "args": [ { "property": "geometry" } ]
    }
  ]
}

I can't find a more recent version of the spec you linked, but the examples in the ogcapi-features repo also follow this format: example 41, example 44

Ariana-B avatar Jul 09 '24 00:07 Ariana-B