-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The $round function returns an empty string when passed a null object #308
Comments
Hi, testing v2.4.9 with the following returns null (no match in Tester): You could change RoundFunction.java line 94: However, this breaks the unit tests and would deviate from the jsonata.org implementation as $round(null,0) should complain about the 1st argument as evidenced in this test: https://try.jsonata.org/X4VtoczxS I'd prefer not to deviate if possible. |
Thanks for the response. Looking into this further, it appears that the empty string only results when storing the result of the round function into a variable: Example:
The result is:
In the above output, the variable |
This seems like a tip of an iceberg... I can patch to return a NullNode but the exists function still shows true since the variable is pointing at a function. And, there are tests from jsonata.org for the function-string.case027, 018, and 028 that expect the empty string when a variable points to a function. I'll revisit in a bit to see if I can determine why it is an empty string sometimes and a NullNode in others. |
When passing a null object to the round function, the returned value is an empty string. A null return value would have been expected (as provided by the javascript implementation of this function). By returning a string, subsequent expressions that may check for zero values, or the existence of a value can fail.
Example using jsonata4java version 2.4.9
Expected result: null (i.e: no result)
Actual result:
""
Result using Javascript version 2.0.5: null / undefined / ** no match **
The text was updated successfully, but these errors were encountered: