Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inplace updating a sequence with an anchor unsets the anchor #1269

Closed
ashwin1dd opened this issue Jul 12, 2022 · 3 comments
Closed

Inplace updating a sequence with an anchor unsets the anchor #1269

ashwin1dd opened this issue Jul 12, 2022 · 3 comments
Labels

Comments

@ashwin1dd
Copy link

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.

@mikefarah
Copy link
Owner

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 mikefarah reopened this Jul 13, 2022
@mikefarah
Copy link
Owner

Sorry github autoclosed - will close when the fix is actually released..

@mikefarah
Copy link
Owner

Fixed in v4.26.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants