camunda / camunda-docs

Camunda 8 Documentation, including all components and features
https://docs.camunda.io/
Other
51 stars 166 forks source link

Unary tests: Comparison between different types does not always return null #3964

Open rodrigo-lourenco-lopes opened 1 week ago

rodrigo-lourenco-lopes commented 1 week ago

We just had this support issue where the customer found one edge case in the unary tests that at first glance does not seem correct. But it is still technically correct.

The case is when we have the input as null in the expression and we have these two:

In the first case this is explained by the fact that we are comparing two different types and therefore we get the null result as is expected and explained in our docs.

The second case is different because the expression will replace the question mark before evaluating if the expression is semantically correct. We get therefore the expression null < 3 which is semantically incorrect and therefore replaced by the expression null, see section 10.3.2.13.1 in the DMN spec. [1]. And since that the default operator in the Unary tests is the = this means that our final expression will be null (our input) = null which is true.

To further illustrate this example, if out inputs were a string or an array, the result of ? < 3 will be false, because a string or an array are different than null.

All this is correct but if I read our documentation of Unary tests I might get the idea that comparisons with different types always return null. Should we add the caveat that if an expression is incorrect it gets replaced with null, and that the default comparator is "="?

akeller commented 1 week ago

found one edge case

πŸ… πŸ˜†

Pull in @christinaausley if you need help with authoring and/or reviewing. πŸ”