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

Merging unnamed lists gives wrong result #24

Open
vpanfilov opened this issue Oct 11, 2019 · 0 comments · May be fixed by #25
Open

Merging unnamed lists gives wrong result #24

vpanfilov opened this issue Oct 11, 2019 · 0 comments · May be fixed by #25

Comments

@vpanfilov
Copy link

When I use sequences of mappings in YAML format (see example 2.4 on https://yaml.org/spec/1.2/spec.html#id2759963) I can't override this array in another config section. Sequences of mappings from YAML are represented as unnamed lists in R.

Here is a simple example (section2 values are not overriden with conf2):

library(yaml)
library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 3.6.1
#> Warning: package 'tidyr' was built under R version 3.6.1
#> Warning: package 'dplyr' was built under R version 3.6.1

conf1 <- yaml::yaml.load("
  param1: 123
  param2: 123
  section1:
    param1: test
    param2: 4
    params3: 8
  section2:
    - key: 1
      value: test1
    - key: 2
      value: test2
    - key: 3
      value: test3
")

conf2 <- yaml::yaml.load("
  param1: 456
  section1:
    param1: test_override
    param2: 8
  section2:
    - key: 4
      value: test4
    - key: 5
      value: test5
")

config::merge(conf1, conf2) %>%
  glimpse()
#> List of 4
#>  $ param2  : int 123
#>  $ section1:List of 3
#>   ..$ params3: int 8
#>   ..$ param1 : chr "test_override"
#>   ..$ param2 : int 8
#>  $ section2:List of 3
#>   ..$ :List of 2
#>   .. ..$ key  : int 1
#>   .. ..$ value: chr "test1"
#>   ..$ :List of 2
#>   .. ..$ key  : int 2
#>   .. ..$ value: chr "test2"
#>   ..$ :List of 2
#>   .. ..$ key  : int 3
#>   .. ..$ value: chr "test3"
#>  $ param1  : int 456

Created on 2019-10-11 by the reprex package (v0.3.0)

vpanfilov added a commit to vpanfilov/config that referenced this issue Oct 11, 2019
Unnamed lists can now be overriden by another config section (see rstudio#24)
vpanfilov added a commit to vpanfilov/config that referenced this issue Oct 11, 2019
Unnamed lists can now be overriden by another config section (fix rstudio#24)
@vpanfilov vpanfilov linked a pull request Oct 11, 2019 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant