mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
Fixed passing of readonly context in pipe
This commit is contained in:
parent
9d3c402923
commit
385921a3e2
@ -14,6 +14,13 @@ var collectObjectOperatorScenarios = []expressionScenario{
|
||||
"D0, P[], (!!map)::dog: great\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
expression: `({} + {}) | (.b = 3)`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!map)::b: 3\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
document: "a: []",
|
||||
|
@ -5,12 +5,12 @@ func pipeOperator(d *dataTreeNavigator, context Context, expressionNode *Express
|
||||
if expressionNode.LHS.Operation.OperationType == assignVariableOpType {
|
||||
return variableLoop(d, context, expressionNode)
|
||||
}
|
||||
|
||||
lhs, err := d.GetMatchingNodes(context, expressionNode.LHS)
|
||||
if err != nil {
|
||||
return Context{}, err
|
||||
}
|
||||
rhs, err := d.GetMatchingNodes(lhs, expressionNode.RHS)
|
||||
rhsContext := context.ChildContext(lhs.MatchingNodes)
|
||||
rhs, err := d.GetMatchingNodes(rhsContext, expressionNode.RHS)
|
||||
if err != nil {
|
||||
return Context{}, err
|
||||
}
|
||||
|
@ -21,6 +21,14 @@ var pipeOperatorScenarios = []expressionScenario{
|
||||
"D0, P[], (doc)::{a: cat, b: dog, c: same}\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
description: "Don't pass readonly context",
|
||||
expression: `(3 + 4) | ({} | .b = "dog")`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!map)::b: dog\n",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestPipeOperatorScenarios(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user