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
... | map(del(.key)) works on collections of records in general, except when applied to the output of to_entries. You can delete other keys, including .value, but specifically not .key. Odder still, if the input file has the same structure as what to_entries creates, you CAN delete the .key record. Examples below.
This behavior changed somewhere between v4.35.2 and v4.40.3.
Version of yq: 4.40.3
Operating system: mac, linux
Installed via: homebrew, asdf, github runner
Input Yaml
input.yml:
test1:
bar: bar1foo: foo1test2:
bar: bar2foo: foo2
input_to_entries.yml:
- key: test1value:
bar: bar1foo: foo1
- key: test2value:
bar: bar2foo: foo2
Command
The command you ran:
yq 'to_entries | map(del(.key))' input.yaml
Actual behavior
- key: test1value:
bar: bar1foo: foo1
- key: test2value:
bar: bar2foo: foo2
Expected behavior
- value:
bar: bar1foo: foo1
- value:
bar: bar2foo: foo2
Additional context
It appears to be something specific about applying to the output of to_entries. If you apply the same transformation two steps via an intermediate file, you can delete the key:
Describe the bug
... | map(del(.key))
works on collections of records in general, except when applied to the output ofto_entries
. You can delete other keys, including.value
, but specifically not.key
. Odder still, if the input file has the same structure as whatto_entries
creates, you CAN delete the.key
record. Examples below.This behavior changed somewhere between v4.35.2 and v4.40.3.
Version of yq: 4.40.3
Operating system: mac, linux
Installed via: homebrew, asdf, github runner
Input Yaml
input.yml:
input_to_entries.yml:
Command
The command you ran:
Actual behavior
Expected behavior
Additional context
It appears to be something specific about applying to the output of
to_entries
. If you apply the same transformation two steps via an intermediate file, you can delete the key:Gives the expected:
This appears to be specific to keys named
key
, as you can delete thevalue
key fromto_entries
output:... gives:
Was working as expected in v4.35.2:
The text was updated successfully, but these errors were encountered: