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

TOML table arrays dropped when defined before parent object properties #1922

Closed
cronik opened this issue Jan 19, 2024 · 2 comments
Closed

TOML table arrays dropped when defined before parent object properties #1922

cronik opened this issue Jan 19, 2024 · 2 comments
Labels

Comments

@cronik
Copy link

cronik commented Jan 19, 2024

Describe the bug
TOML table arrays dropped when defined before parent object properties. In otherwords, if you take the test case from toml_test.go and re-order the sections such the the "owner" section is after the "owner.addresses" sections the "addresses" field is dropped/deleted.

Version of yq: v4.40.5
Operating system: alpine linux
Installed via: binary

Input Toml

data1.toml:

[[owner.addresses]]
street = "first street"
suburb = "ok"

[[owner.addresses]]
street = "second street"
suburb = "nice"

[owner]
name = "Tom Preston-Werner"
age = 36

Command
The command you ran:

yq -oj .  data1.toml

Actual behavior

{
  "owner": {
    "name": "Tom Preston-Werner",
    "age": 36
  }
}

Expected behavior

{
  "owner": {
    "name": "Tom Preston-Werner",
    "age": 36,
    "addresses": [
      {
        "street": "first street",
        "suburb": "ok"
      },
      {
        "street": "second street",
        "suburb": "nice"
      }
    ]
  }
}

Additional context
The go-toml library seems to handle this as expected (see https://go.dev/play/p/D04-xTgNjx9 ), so I suspect there might be something in decoder_toml.go

@mikefarah
Copy link
Owner

Thanks for raising 👍🏼 will fix in the next release

@mikefarah
Copy link
Owner

Fixed in 4.41.1

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