yq
yq copied to clipboard
Square brackets removing update
Describe the bug Coming from jq I am kind of expecting enclosing a whole expression in square brackets will force an array of the result but i seem to lose my update if i enclose one
i think the most minimal example is this:
.coll | to_entries | .[] | .value.test = "test"
updates each object with an extra field
key: key1
value:
type: a
name: key1
list:
- one
- two
test: test
key: key2
value:
type: b
name: key2
list:
- three
- four
test: test
key: key3
value:
type: a
name: key3
list:
- five
- six
test: test
[.coll | to_entries | .[] | .value.test = "test"]
returns basically the original yaml (if I pipe to from_entries) but you can see it in the example that the additional field does not appear
- key: key1
value:
type: a
name: key1
list:
- one
- two
- key: key2
value:
type: b
name: key2
list:
- three
- four
- key: key3
value:
type: a
name: key3
list:
- five
- six
Version of yq: 4.27.5 Operating system: mac/linux/windows/.... Installed via: macos brew
Input Yaml Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less) data1.yml:
field: value
coll:
key1:
type: a
name: key1
list:
- one
- two
key2:
type: b
name: key2
list:
- three
- four
key3:
type: a
name: key3
list:
- five
- six
Command The command you ran:
yq 'see above' data1.yml