Skip to content

Merging objects behaves strange with eval-all #2524

@Wikiwix

Description

@Wikiwix

I am not 100% certain that this is a bug instead of me not understanding some special behaviour:

printf  '{"a":1}\n{"a":2}\n{"a":3}\n'  | yq --input-format=json --output-format=json ea '[.] | map(. * {"b":0})'

Returns

[
  {
    "a": 1,
    "b": 0
  },
  {
    "a": 1,
    "b": 0
  },
  {
    "a": 1,
    "b": 0
  },
  {
    "a": 2,
    "b": 0
  },
  {
    "a": 2,
    "b": 0
  },
  {
    "a": 2,
    "b": 0
  },
  {
    "a": 3,
    "b": 0
  },
  {
    "a": 3,
    "b": 0
  },
  {
    "a": 3,
    "b": 0
  }
]

Whereas I would have expected it to output

[{"a": 1, "b": 0}, {"a": 2, "b": 0}, {"a": 3, "b": 0}]

which one gets when using this:

printf  '{"a":1}\n{"a":2}\n{"a":3}\n'  | yq --input-format=json --output-format=json ea '[.]' | yq 'map(. * {"b":0})'

So it appears to be related to the eval-all, but I don't understand what is going on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions