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

strange behavior with nested array #618

Closed
abenaguev opened this issue Dec 23, 2020 · 2 comments
Closed

strange behavior with nested array #618

abenaguev opened this issue Dec 23, 2020 · 2 comments
Labels
Milestone

Comments

@abenaguev
Copy link

abenaguev commented Dec 23, 2020

hello. not really sure this is a bug, not some dark yamel corners. so we have test.ymel like this:

a:
  b:
  - 0
  - 1
  - 2
  - 3

then yq eval '.a.b.[] | path | .[-1]' test.yaml works as expected:

0
1
2
3

let's add some nesting:

a:
  b:
    c:
    - 0
    - 1
    - 2
    - 3

and eval '.a.b.c.[] | path | .[-1]' test.yaml give us:

3
3
3
3

what is really weird: looks like it's OK when array is nested to 2^n levels

  • yq eval '.a.[] | path | .[-1]' test.yaml - 2^0, OK
  • yq eval '.a.b.[] | path | .[-1]' test.yaml - 2^1, OK
  • yq eval '.a.b.c.d.[] | path | .[-1]' test.yaml - 2^2, OK
  • yq eval '.a.b.c.d.e.f.g.h.[] | path | .[-1]' test.yaml - 2^3, ОК
  • yq eval '.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.[] | path | .[-1]' test.yaml - 2^4, OK

here I stop and open this issue

Version of yq: 4.1.0
Operating system: linux
Installed via: binary release

p.s. would like to take this opportunity to warmly thank Mike for success years whith yq 🖖
p.p.s. I really love new eval syntax. wtg

upd. seems like #589

@abenaguev
Copy link
Author

hi. me again. try to merge some old docker-composes. and yes, yq4 processed only last element from arrays. can't repeat with yq3
image

@mikefarah
Copy link
Owner

Think I've found the bug in the code - thanks for the clear ticket! Will fix in the next release.

@mikefarah mikefarah added this to the 4.1.1 milestone Dec 25, 2020
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

2 participants