Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 multiply operator (merge) dropping object level anchors #694

Closed
nknotts opened this issue Jan 28, 2021 · 5 comments
Closed

v4 multiply operator (merge) dropping object level anchors #694

nknotts opened this issue Jan 28, 2021 · 5 comments
Labels
Milestone

Comments

@nknotts
Copy link

nknotts commented Jan 28, 2021

Describe the bug
When using the V4 yq multiply operator, any anchor associated with an object node appears to be dropped in the output.

Version of yq: 4.4.1
Operating system: macOS 11.1
Installed via: homebrew

Input Yaml

a.yml:

foo: &foo-alias
  bar: &bar-alias baz
  a: &c-node
    b: &b-node c

b.yml:

test: &test-alias
  node: &node-alias 1

Command

yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' a.yml b.yml

Actual behavior

foo:
  bar: &bar-alias baz
  a:
    b: &b-node c
test:
  node: &node-alias 1

Expected behavior

foo: &foo-alias
  bar: &bar-alias baz
  a: &c-node
    b: &b-node c
test: &test-alias
  node: &node-alias 1

Additional context
When using yq version 3.4.1 command yq merge a.yml b.yml, the expected behavior is generated

@mikefarah
Copy link
Owner

Looks like this is related to: #677

@mikefarah mikefarah added this to the 4.5.1 milestone Feb 5, 2021
@mikefarah
Copy link
Owner

Fixed in 4.5.1

@nknotts
Copy link
Author

nknotts commented Feb 10, 2021

Confirmed! Thank you so much.

@brewdium
Copy link

Confirmed that it's fixed for me too, muchas gracias

@styu99
Copy link

styu99 commented Jul 19, 2021

I still seem to be having this issue when using the + (append) merge flag @mikefarah

Input yaml
a.yml:

:test:
  :foo: &common
    - PROP_A
  :bar:
    - *common
    - TEST

b.yml:

:test:
  :foo: &common
    - PROP_B

Command
yq eval-all 'select(fileIndex == 0) *+ select(fileIndex == 1)' a.yml b.yml > c.yml
Actual output
c.yml:

:test:
  :foo:
    - PROP_A
    - PROP_B
  :bar:
    - *common
    - TEST

Expected output
c.yml:

:test:
  :foo: &common
    - PROP_A
    - PROP_B
  :bar:
    - *common
    - TEST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants