Skip to content

Commit

Permalink
Fixed bug in castForImport drops #331
Browse files Browse the repository at this point in the history
  • Loading branch information
spgarbet committed Mar 25, 2024
1 parent 441e489 commit 3684d51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/fieldCastingFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,15 @@ castForImport <- function(data,
data <- data[,!mchoices, drop=FALSE]
fields <- fields[!mchoices]
}

# Drop non importable field types
for(type in c("file", "calc"))
{
drops <- rcon$metadata()[match(fields, rcon$metadata()$field_name),'field_type'] == type
if(!is.na(sum(drops)) && sum(drops) > 0)
drops[is.na(drops)] <- FALSE
if(sum(drops) > 0)
{
message(paste0("The following ", type, ", variables(s) were dropped: ",
message(paste0("The following ", type, " variables(s) were dropped: ",
paste0(fields[drops], collapse=', '), '.'))
data <- data[,!drops, drop=FALSE]
fields <- fields[!drops]
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-201-exportTypedRecords-withDAGs.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ImportData <- exportRecordsTyped(rcon,
cast = raw_cast)
ImportData <- castForImport(ImportData,
rcon,
validation = list(bioportal=valSkip),
cast = list(number_1dp = as.numeric,
number_2dp = as.numeric,
number_1dp_comma_decimal = as.numeric,
Expand Down

0 comments on commit 3684d51

Please sign in to comment.