frictionless-r icon indicating copy to clipboard operation
frictionless-r copied to clipboard

127 compare header and schema

Open PietrH opened this issue 1 year ago • 1 comments

PietrH avatar Aug 03 '23 12:08 PietrH

check_schema() fails on case mismatch between schema and data. To replicate:

# create package with the wrong case in the schema of observations
  wrong_case_in_schema_pkg <- example_package
  ## change case
  purrr::pluck(wrong_case_in_schema_pkg, "resources", 2, "schema", "fields") <-
    purrr::chuck(wrong_case_in_schema_pkg, "resources", 2, "schema", "fields") %>%
    purrr::map2_chr(
      c(TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE), #set some to upper, some to lower case
      ~ ifelse(.y,
        toupper(purrr::chuck(.x, "name")),
        tolower(purrr::chuck(.x, "name"))
      )
    )
read_resource(wrong_case_in_schema_pkg, "observations")

Fails on:

https://github.com/frictionlessdata/frictionless-r/blob/7dba18d98afe46480367ef2f878160efecb7e629/R/check_schema.R#L19-L20

Error in `purrr::map_chr()` at frictionless-r/R/check_schema.R:20:2:
ℹ In index: 1.
Caused by error in `.x$name`:
! $ operator is invalid for atomic vectors
Run `rlang::last_trace()` to see where the error occurred.

PietrH avatar Aug 03 '23 12:08 PietrH