Skip to content

Commit 2d4f1d4

Browse files
committed
check diff of expected and actual field names, since user can request subset
1 parent 83d7813 commit 2d4f1d4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

R/model.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,23 @@ parse_value <- function(info, value, disable_date_parsing = FALSE) {
138138
value
139139
}
140140

141+
#' @importFrom purrr map_chr
141142
parse_data_frame <- function(epidata_call, df, disable_date_parsing = FALSE) {
142143
stopifnot(inherits(epidata_call, "epidata_call"))
143144
meta <- epidata_call$meta
144145
df <- as.data.frame(df)
145146

146-
if (length(meta) != 0 && ncol(df) != length(meta)) {
147-
cli::cli_warn("Not all return columns are specified as expected epidata fields")
148-
}
149-
150147
if (length(meta) == 0) {
151148
return(df)
152149
}
150+
151+
meta_field_names <- map_chr(meta, ~ .x$name)
152+
if (
153+
length(setdiff(names(df), meta_field_names)) != 0
154+
) {
155+
cli::cli_warn("Not all return columns are specified as expected epidata fields")
156+
}
157+
153158
columns <- colnames(df)
154159
for (i in seq_len(length(meta))) {
155160
info <- meta[[i]]

0 commit comments

Comments
 (0)