Skip to content

Commit

Permalink
Adding acceptance test for #1257, fixed panic
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed Jun 25, 2022
1 parent 9b47a29 commit 06d2aaa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions acceptance_tests/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,26 @@ EOM
assertEquals "$expected" "$X"
}

testBasicMultiplyAssignMultiDoc() {
cat >test.yml <<EOL
a: 1
---
b: 2
EOL

read -r -d '' expected << EOM
a: 1
c: 3
---
b: 2
c: 3
EOM


X=$(./yq '. *= {"c":3}' test.yml)
assertEquals "$expected" "$X"
}



source ./scripts/shunit2
2 changes: 2 additions & 0 deletions pkg/yqlib/operator_assign.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func assignUpdateOperator(d *dataTreeNavigator, context Context, expressionNode
}

prefs := assignPreferences{}
// they way *= (multipleAssign) is handled, we set the multiplePrefs
// on the node, not assignPrefs. Long story.
if p, ok := expressionNode.Operation.Preferences.(assignPreferences); ok {
prefs = p
}
Expand Down
3 changes: 3 additions & 0 deletions release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
4.25.4:
- Fixed panic when using multiply assign on multiple documents #1256 Thanks @care0717

4.25.3:
- xml decoder now maintains namespaces by default. Use new flags to disable if required. Thanks @rndmit
- Length and other similar operators no longer return comments (#1231)
Expand Down

0 comments on commit 06d2aaa

Please sign in to comment.