-
Notifications
You must be signed in to change notification settings - Fork 51
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
Expression for Context's Get entry/path with optional entries. #540
Comments
@pme123 thank you for raising this up. 👍 As a workaround, you could write the following expression:
However, the null check is not very elegant. The proposal by using a new operator |
That would work as well. Maybe also more readable for a non-programmer;). We could extend the existing one
|
We could already use the
|
This is great. |
@saig0 I checked the code and added some Test cases. So what you propose is working already with the following warning:
The function would IMHO look a bit nicer if we only had to have the path as parameter. So I tried that and this worked exactly the same with the above warning. So what you think - shall I make a pull request for: And maybe we need to change the Warning to an Info. |
I thought about the issue and different solutions. Currently, my favorite solution would be: Modify the get value() function and introduce a new parameter list. In addition to
If one of the keys is not part of the context then the function returns The context put function has also a parameter @pme123 would this solution fit your case? |
Hi @saig0 |
The semantics. The The function Alternatively, we could introduce a new function for this case. For example, Additional context for the |
Ok, in this case my favourite would be |
Came up in the context of "null" safety discussion internally. Up for clarification: What is the intention of the DMN spec.
|
Update: the get value(context, keys) function is available since version |
Based on the discussions (#582, #572), we came to the conclusion that the FEEL engine should handle non-existing variables (and properties) gracefully and return There is an open issue for clarifying the behavior in the DMN-TCK: dmn-tck/tck#537. |
The expected behavior was clarified by merging the new TCK test case. |
I'm closing this issue in favor of #674. It sums up the finding in this issue but as a bug report. |
Is your feature request related to a problem? Please describe.
In contexts we have often the two cases a path / entry exists or it doesn't. With the construct (if then else) we have now, it is hard to work with.
Example:
If b, c, and d is required the path is easy:
b.c.d
But if these values are optional there is no simple way to get d if it exists.
Describe the solution you'd like
For Scripting like in Groovy, you can do
b?.c?.d
, which will return null if one of these entries are missing.Supporting this would help a lot working with data structures in Camunda 8 processes.
The text was updated successfully, but these errors were encountered: