-
Notifications
You must be signed in to change notification settings - Fork 159
Context Data Update Behavior #867
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
Comments
Well, yet another excellent question 😆 My opinion on this is that the result should be overwritten. The reason is that, as you said, I feel that if we just extend, we would throw down the bin some very cool |
I think the problem is the ambiguity of to. |
To is ambiguous indeed. However it is not solved imho by using merge or set, as it's the content of the jq expression which (should) decide what to do (just update, replace or merge). |
I agree. I don't think But I also think there is a problem with relying on jq expressions to handle updates (this is my understanding of how jq works, so correct me if I am wrong): jq can only operate in the context of one object. given: {
"context": {
"foo": "bar"
},
"output": {
"a": 1
}
} and the following output expression: output:
to: '.b = [$.context.foo, .a]' The desired output would be: {
"foo": "bar",
"b": ["bar", 1]
} If this expression is now run in the context of {
"foo": "bar",
"b": ["bar", null]
} because {
"a": 1,
"b": ["bar", 1]
} which is the modified Because of that I think it would make the most sense if:
a potential rename of the |
@matthias-pichler-warrify I think it was crystal clear the expression should be run in the context of output and we were discussing what to do with the result of the expression evaluation. |
@matthias-pichler-warrify Yes, that is correct. The operand being the "input". ... but you have parameters, which brings me to the |
@fjtirado That's an intersting idea indeed. I feel however it adds additional properties for something that is already explicitly written by the user, which is the expression. If the user writes an expression that overwrites the context, so be it: if she's smart enough to write the expression, let's assume she's smart enough to understand it ^^. If we choose to rename I'm not even sure there's a need to rename at all, the issue as I understand it being more about explicitly settling on/documenting the behavior. |
@cdavernas
where the string is always an exprerssion and is context. However since it seems we do not consider any other action than replacing the context, we can perfectly write |
Renaming is not the point here: it's off topic. If that's something you think it's necessary, let's open an issue or a discussion about it 😉
As said in my previous commentary, I see no need to "split" the functionality of the expression feature into two different variables. |
@cdavernas what Im saying is that you do not need
just
will do it |
I understand what you wrote. What I said it's that it's off topic. Plus, your last proposal leaves out schema. Anyways, please move that to another issue/discussion. |
How is this a different discussion if we are just discussing how to update the context? |
@matthias-pichler-warrify Hasn't this been addressed and closed by #873 ? |
@matthias-pichler-warrify can we close this issue? |
What would you like to be added:
The
output.to
field allows to write data to the context. Is the context merged or overwritten by the data produced by this expression?given a context of
will the expression
result in
or
Personally always extending makes sense to me from a usability perspective but it seems to me that context could really explode in size this way. Especially because jq has built in methods for extending objects, such as
or
which both are more explicit about extending
Why is this needed:
This is relevant for making sure data flow is implemented correctly and context does not explode in size.
The text was updated successfully, but these errors were encountered: