Skip to content

Extracting object values by iterating via keys causes missing items #2593

@ryenus

Description

@ryenus

Describe the bug
Extracting object values by iterating via keys causes missing items, see the example below:

Version of yq: 4.45.2
Operating system: mac
Installed via: homebrew

Command
The command you ran:

echo '["a","b"]' | yq '. as $o | keys[] | $o[.]'

Actual behaviour

a

Expected behaviour

a
b

Additional context
The problem appears to be related to the $o[.] part, somehow it only produced the value of the first key (index 0).

However, it works when iterating over keys[] with an intermediate variable, e.g.:

  • echo '["a","b"]' | yq '. as $o | keys[] | . as $k | $o[$k]'
  • echo '["a","b"]' | yq '. as $o | keys[] | . as $k | $o[.]' ## $k is not even used

Both would produce the expected result mentioned above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions