We've found 2 tests in CqlListOperatorsTest that appear to have inconsistent handling of nulls:
- ProperContains9:
{ 'a', null } properly includes 'a' ==> null
|
<test name="ProperContains9" version="1.0"> |
|
<capability code="list-operators" /> |
|
<expression>{ 'a', null } properly includes 'a'</expression> |
|
<output>null</output> |
|
</test> |
This one we believe is correct. From the ProperContains spec,
this operator returns true if the given element is in the list, and it is not the only element in the list, using equality semantics, with the exception that null elements are considered equal.
(Note we interpret "not the only element" to mean "not the only unique element" here, and a pseudocode for how we would implement ProperContains is list.any?(e -> givenElement == e) and list.any?(e -> givenElement != e) )
In this example, the given element 'a' is in the list, but by the usual equality semantics, null == 'a' evaluates to null, and so evaluating "is it the only element in the list?" must evaluate to null as well and that bubbles up into the overall result.
and
- ContainsNullFirst:
{ null, 'b', 'c' } contains 'a' ==> false
|
<test name="ContainsNullFirst" version="1.0"> |
|
<capability code="list-operators" /> |
|
<expression>{ null, 'b', 'c' } contains 'a'</expression> |
|
<output>false</output> |
|
</test> |
This one we believe is incorrect, and the expected output should instead be null
From the Contains spec,
this operator returns true if the given element is in the list, using equality semantics, with the exception that null elements are considered equal.
In this example, again we have an equality comparison that results in null: null == 'a', none of the comparisons result in true, and so as before this should bubble up to be null for the overall result.
Are we maybe missing something? Or possibly should we be interpreting the null-equality semantics differently in one of these cases?
We've found 2 tests in CqlListOperatorsTest that appear to have inconsistent handling of nulls:
{ 'a', null } properly includes 'a'==>nullcql-tests/tests/cql/CqlListOperatorsTest.xml
Lines 899 to 903 in 0666708
This one we believe is correct. From the ProperContains spec,
(Note we interpret "not the only element" to mean "not the only unique element" here, and a pseudocode for how we would implement ProperContains is
list.any?(e -> givenElement == e) and list.any?(e -> givenElement != e))In this example, the given element 'a' is in the list, but by the usual equality semantics,
null == 'a'evaluates tonull, and so evaluating "is it the only element in the list?" must evaluate to null as well and that bubbles up into the overall result.and
{ null, 'b', 'c' } contains 'a'==>falsecql-tests/tests/cql/CqlListOperatorsTest.xml
Lines 70 to 74 in 0666708
This one we believe is incorrect, and the expected output should instead be
nullFrom the Contains spec,
In this example, again we have an equality comparison that results in null:
null == 'a', none of the comparisons result intrue, and so as before this should bubble up to benullfor the overall result.Are we maybe missing something? Or possibly should we be interpreting the null-equality semantics differently in one of these cases?