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

Unexpected behavior with lists #53

Closed
kieran-mace opened this issue Nov 15, 2024 · 2 comments
Closed

Unexpected behavior with lists #53

kieran-mace opened this issue Nov 15, 2024 · 2 comments

Comments

@kieran-mace
Copy link

kieran-mace commented Nov 15, 2024

It seems that lists are being merged with default when they are missing an element. I would have expected the members object to not borrow from default if it has been declared within a config.

yaml <- '
default:
  department_name: "Whole Company"
  members:
    - name: John
      age: 30
    - name: Jane
      age: 25
    - name: Sally
      age: 35

data_science:
  department_name: "Data Science"
  members:
    - name: John
      age: 30
    - name: Jane
      age: 25
'

config::with_config(yaml, config::get("members", config = "data_science"))
#> [[1]]
#> [[1]]$name
#> [1] "John"
#> 
#> [[1]]$age
#> [1] 30
#> 
#> 
#> [[2]]
#> [[2]]$name
#> [1] "Jane"
#> 
#> [[2]]$age
#> [1] 25
#> 
#> 
#> [[3]]
#> [[3]]$name
#> [1] "Sally"
#> 
#> [[3]]$age
#> [1] 35

Specifically, in this example, Sally should not show up in the data_science configuration.

Created on 2024-11-15 with reprex v2.1.1

@kieran-mace
Copy link
Author

If there is another way of structuring this data to achieve the desired effect, I'd be open to that too - It does however seem this would be the desirred behavior.

@andrie
Copy link
Member

andrie commented Nov 15, 2024

We should document this better, but it is expected behaviour.

The new values get merged recursively into the default values.

I could probably invent workaround using two separate values for all_members and team_members and then have logic in your app that merges / replaces these in the way you want.

@andrie andrie closed this as completed Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants