Skip to content

Commit 6bf3def

Browse files
committed
Fixing updates in square brackets #1342
1 parent 6d6b693 commit 6bf3def

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/yqlib/operator_collect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func collectOperator(d *dataTreeNavigator, context Context, expressionNode *Expr
5656
collectedNode := &yaml.Node{Kind: yaml.SequenceNode, Tag: "!!seq"}
5757
collectCandidate := candidate.CreateReplacement(collectedNode)
5858

59-
collectExpResults, err := d.GetMatchingNodes(context.SingleReadonlyChildContext(candidate), expressionNode.RHS)
59+
collectExpResults, err := d.GetMatchingNodes(context.SingleChildContext(candidate), expressionNode.RHS)
6060
if err != nil {
6161
return Context{}, err
6262
}

pkg/yqlib/operator_collect_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ var collectOperatorScenarios = []expressionScenario{
2020
"D0, P[], (!!seq)::- 1\n- 2\n- 3\n",
2121
},
2222
},
23+
{
24+
skipDoc: true,
25+
description: "update in collect",
26+
expression: `[.a = "cat"]`,
27+
expected: []string{
28+
"D0, P[], (!!seq)::- a: cat\n",
29+
},
30+
},
2331
{
2432
description: "Collect empty",
2533
document: ``,

0 commit comments

Comments
 (0)