Closed aznan2 closed 8 months ago
@aznan2 - Thank you for reporting. Issues with the schema were reported last week in #901 and were fixed with PR #902. This includes an upgrade to 2020-12 and as far as I can tell also the other issues that you have reported. Can you try again with the updated schema? Thanks!
Oh, I missed that issue. Everything works fine now. The only housekeeping thing one could do is remove scalarLiteral
, since that is not referenced anymore.
Thanks @aznan2, also for pointing out that scalarLiteral
is not referenced. I will remove it.
With the release of RC1, I took a look at the CQL2 JSON Schema and noticed that validating filters got me unexpected results.
First off, my validator would complain that the schema uses
$dynamicAnchor
and$dynamicRef
which were intoduced in draft 2020-12, so the value of$schema
should behttps://json-schema.org/draft/2020-12/schema
. And following that,additionalItems
was removed in draft 2020-12, so line 224 inisBetweenOperands
should be removed.After having made those changes it only got worse. Consider two basic equality filters, the first one is correct and the second is incorrect:
However, when validating against the current schema, the first instance fails validation and the second one passes. This is because in
functionRef
in the schema, theop
property can be any string, even=
. The root of the schema has aoneOf
that containscomparisonPredicate
andfunctionRef
. Since the first instance is both a validcomparisonPredicate
and a valid function named=
, theoneOf
fails. Similarly, the second instance passes the validation, again because it is a valid function named=
.^ BTW, Example 24 still uses the old function syntax for JSON.
From the above trail, I can deduce that
=
is not a valid function name, but the schema validator doesn't know that. For the validation to work theop
property offunctionRef
needs to be defined in a way so that it doesn't clash with any predefined keyword. Possibly something like this:I couldn't figure out how to include the last group,
"\x10000".."\xEFFFF"
, in the regex. But the pattern could be skipped entirely if"=", "<>", "<", ">", "<=", ">=", "+", "-", "*", "/", "^", "%"
would be included in the enum.