Skip to content

Commit 83d7813

Browse files
committed
don't try to convert date fields to date again; warn if meta and return values have diff number of fields
1 parent a43ea6f commit 83d7813

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

R/model.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ parse_value <- function(info, value, disable_date_parsing = FALSE) {
122122

123123
if (is.null(value)) {
124124
return(value)
125-
} else if (info$type == "date" && !disable_date_parsing) {
125+
} else if (info$type == "date" && !disable_date_parsing && !inherits(value, "Date")) {
126126
return(parse_api_date(value))
127-
} else if (info$type == "epiweek" && !disable_date_parsing) {
127+
} else if (info$type == "epiweek" && !disable_date_parsing && !inherits(value, "Date")) {
128128
return(parse_api_week(value))
129129
} else if (info$type == "bool") {
130130
return(as.logical(value))
@@ -142,6 +142,11 @@ parse_data_frame <- function(epidata_call, df, disable_date_parsing = FALSE) {
142142
stopifnot(inherits(epidata_call, "epidata_call"))
143143
meta <- epidata_call$meta
144144
df <- as.data.frame(df)
145+
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+
145150
if (length(meta) == 0) {
146151
return(df)
147152
}

0 commit comments

Comments
 (0)