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

Add new object to existing array object is failing in 3.1.1 #361

Closed
dben1713 opened this issue Feb 17, 2020 · 1 comment
Closed

Add new object to existing array object is failing in 3.1.1 #361

dben1713 opened this issue Feb 17, 2020 · 1 comment
Labels
Milestone

Comments

@dben1713
Copy link

Using the latest version of yq appears to break being able to add new objects to an existing array object, this was working fine as of version 2.4.1.

With this file:

applications:
  - name: app
    env:

I cannot use write to add an additional field to the 'env' object. I would expect this
yq w hello.yml "applications[0].env.hello" "world"
to output the following:

applications:
  - name: app
    env:
      hello: world

However, I am just getting the follow output:

applications:
  - name: app
    env:

I'm not sure if this is a result of the breaking change regarding "reading paths that don't exist" with the new version or not.

Adding new nodes to the array seems to work fine:
yq w -v hello.yml "applications[0].hello" "WORLD"

applications:
  - name: app
    env:
    hello: WORLD

yq w -v hello.yml "applications[0].hello.foo" "WORLD"

applications:
  - name: app
    env:
    hello:
      foo: WORLD

But I need to be able to update an existing node in the array. This is probably related to #356.

@dben1713 dben1713 changed the title Add new field to array object is failing in 3.1.1 Add new object to existing array object is failing in 3.1.1 Feb 17, 2020
@mikefarah mikefarah added the bug label Feb 18, 2020
@mikefarah mikefarah modified the milestones: 3.1.3, 3.1.2 Feb 18, 2020
mikefarah added a commit that referenced this issue Feb 18, 2020
@mikefarah
Copy link
Owner

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