Closed
Description
Describe the bug
Appending to a sequence inplace unsets its anchor.
It shouldn't affect the anchor at all, and should've only affected the sequence.
Version of yq: 4.25.3
Operating system: mac
Installed via: homebrew
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data1.yml:
a: &hello
- x
- y
b: *hello
Command
The command you ran:
yq -i '.a += ["z"]' data1.yml
Actual behavior
a:
- x
- y
- z
b: *hello
Expected behavior
a: &hello
- x
- y
- z
b: *hello
Additional context
Add any other context about the problem here.
Activity
mikefarah commentedon Jul 13, 2022
Yep that's a bug - will fix in the next release.
As a workaround, you can do the following:
yq '.a = .a + "z"' file.yaml
mikefarah commentedon Jul 13, 2022
Sorry github autoclosed - will close when the fix is actually released..
mikefarah commentedon Jul 15, 2022
Fixed in v4.26.1
Dont clobber anchor when adding nodes - fixes mikefarah#1269