number() on a number returns null
LockeBirdsey opened this issue · 3 comments
Describe the bug
Due to unexpected value types in a retrieved value, we sanitise types by number(value)
. When value
is already a number, number(value)
returns null
To Reproduce
Steps to reproduce the behavior:
number("17")
will return17
number(17)
will returnnull
Expected behavior
number(value)
should return a numeric representation of value
unless there is no possible way for the cast to occur e.g. it is not a primitive.
To be fair, it makes sense that it returns null in this case and that we could further prevent against this issue by doing number(string(value))
. Additionally the Zeebe docs do seem to say the input needs to be a string, so I'm not entirely certain if what I'm reporting is entirely valid or not.
Environment
- Zeebe 8.1.4
@LockeBirdsey thank you for raising this up. 👍
First of all, I understand your expectation.
But the current behavior matches the documentation since the function expects a string argument.
The behavior is also aligned with the DMN specification (chapter 10.3.4.1, page 138):
The number()
function is only defined for string arguments. As a result, the function should return null
for other arguments.
To sum it up, it is the expected behavior from the DMN perspective. So, we can't treat the behavior as a bug.
@LockeBirdsey do you understand the reasoning? Can you agree with it?
Feel free to share your example. I could tweak the expression with you.
Ahh yes that makes complete sense, thanks for the info!
I'll handle my problem in a different way then.