You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I've discovered that contrary to the documentation it seems that yq has somewhat different behavior between . += something and . = . + something. The shorthand operator uses last RHS value everywhere, even if this value should be different across the modified nodes.
Version of yq: 4.23.1
Operating system: Debian GNU/Linux 11 (bullseye)
Installed via: binary release, downloaded from GitHub
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data.yml:
Note that with(.items[]; . = . + {"key": . | key}) works, producing the expected result.
Also, I totally realize that this is a weird expression that should've been just .key = key - this is unfortunate result of distilling the issue straight to the point. In real-world situation I have a complex data structure where I'm appending an item to an array nested inside a map with part of this item dependent on the top-level map key.
Actual behavior
items:
foo:
is: fookey: bazbar:
is: barkey: bazbaz:
is: bazkey: baz
Expected behavior
items:
foo:
is: fookey: foobar:
is: barkey: barbaz:
is: bazkey: baz
And last but not least - thank you for a very useful tool! I've recently discovered yq when I was looking for something to preprocess huge CI configuration document and yq is truly a lifesaver.
The text was updated successfully, but these errors were encountered:
Describe the bug
I've discovered that contrary to the documentation it seems that yq has somewhat different behavior between
. += something
and. = . + something
. The shorthand operator uses last RHS value everywhere, even if this value should be different across the modified nodes.Version of yq: 4.23.1
Operating system: Debian GNU/Linux 11 (bullseye)
Installed via: binary release, downloaded from GitHub
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data.yml:
Command
The command you ran:
Note that
with(.items[]; . = . + {"key": . | key})
works, producing the expected result.Also, I totally realize that this is a weird expression that should've been just
.key = key
- this is unfortunate result of distilling the issue straight to the point. In real-world situation I have a complex data structure where I'm appending an item to an array nested inside a map with part of this item dependent on the top-level map key.Actual behavior
Expected behavior
And last but not least - thank you for a very useful tool! I've recently discovered yq when I was looking for something to preprocess huge CI configuration document and yq is truly a lifesaver.
The text was updated successfully, but these errors were encountered: