Fixing updates in square brackets #1342

This commit is contained in:
Mike Farah 2022-10-24 17:55:19 +11:00
parent 6d6b693fb3
commit 6bf3defe85
2 changed files with 9 additions and 1 deletions

View File

@ -56,7 +56,7 @@ func collectOperator(d *dataTreeNavigator, context Context, expressionNode *Expr
collectedNode := &yaml.Node{Kind: yaml.SequenceNode, Tag: "!!seq"}
collectCandidate := candidate.CreateReplacement(collectedNode)
collectExpResults, err := d.GetMatchingNodes(context.SingleReadonlyChildContext(candidate), expressionNode.RHS)
collectExpResults, err := d.GetMatchingNodes(context.SingleChildContext(candidate), expressionNode.RHS)
if err != nil {
return Context{}, err
}

View File

@ -20,6 +20,14 @@ var collectOperatorScenarios = []expressionScenario{
"D0, P[], (!!seq)::- 1\n- 2\n- 3\n",
},
},
{
skipDoc: true,
description: "update in collect",
expression: `[.a = "cat"]`,
expected: []string{
"D0, P[], (!!seq)::- a: cat\n",
},
},
{
description: "Collect empty",
document: ``,