I came across this while adding some filter cases to the CTS.
$[?@.a!=null]
[{"d": "e"}, {"a":"c", "d": "f"}]
Is {"d": "e"} selected?
Relevant text from the spec:
When a path resulting in an empty nodelist appears on either side of a comparison:
a comparison using the operator == yields true if and only if the comparison is between two paths each of which result in an empty nodelist.
a comparison using the operator < yields false.
and later
!=, <=, >, and >= are defined in terms of the other comparison operators. For any a and b:
The comparison a != b yields true if and only if a == b yields false.
The comparison a <= b yields true if and only if a < b yields true or a == b yields true.
The comparison a > b yields true if and only if b < a yields true.
The comparison a >= b yields true if and only if b < a yields true or a == b yields true.
So DNE == DNE evaluates as true, implying that
DNE != DNE returns false
DNE != anything returns true
I'm not so sure about DNE != anything being true, but as long as it's well-defined, I could be okay with it.
Since DNE < 42 returns false,
DNE > 42 would return false because 42 < DNE returns false
DNE >= 42 -> DNE > 42 || DNE == 42->false || falsewould returnfalse`
Okay. I think this makes sense.
If all this is right, then my original question about {"d": "e"} would boil down to DNE != null which would evaluate to true, so it would be returned. To set up the expression so that it is not returned, it'd have to be $[?@a && @.a!=null].
I came across this while adding some filter cases to the CTS.
Is
{"d": "e"}
selected?Relevant text from the spec:
and later
So
DNE == DNE
evaluates astrue
, implying thatDNE != DNE
returnsfalse
DNE != anything
returnstrue
I'm not so sure about
DNE != anything
beingtrue
, but as long as it's well-defined, I could be okay with it.Since
DNE < 42
returnsfalse
,DNE > 42
would returnfalse
because42 < DNE
returnsfalse
DNE >= 42
-> DNE > 42 || DNE == 42->
false || falsewould return
false`Okay. I think this makes sense.
If all this is right, then my original question about
{"d": "e"}
would boil down toDNE != null
which would evaluate totrue
, so it would be returned. To set up the expression so that it is not returned, it'd have to be$[?@a && @.a!=null]
.Can someone verify all that, please?