diff --git a/R/ResultExportManager.R b/R/ResultExportManager.R index 7c2d269..a372e1c 100644 --- a/R/ResultExportManager.R +++ b/R/ResultExportManager.R @@ -33,18 +33,19 @@ ResultExportManager <- R6::R6Class( tables = NULL, tableSpecification = NULL, databaseId = NULL, + validateTypes = FALSE, connection = NULL, minCellCount = 5, .colTypeValidators = list( - "numeric" = checkmate::checkNumeric, - "int" = checkmate::checkIntegerish, - "varchar" = checkmate::checkCharacter, + "numeric" = checkmate::testNumeric, + "int" = checkmate::testIntegerish, + "varchar" = checkmate::testCharacter, "bigint" = function(x, ...) { - all(checkmate::checkNumeric(x = x, ...) & x %% 1 == 0) + all(checkmate::testNumeric(x = x, ...) & x %% 1 == 0) }, - "float" = checkmate::checkNumeric, - "character" = checkmate::checkCharacter, - "date" = checkmate::checkDate + "float" = checkmate::testNumeric, + "character" = checkmate::testCharacter, + "date" = checkmate::testDate ), getPrimaryKeyCache = function(exportTableName) { file.path(tempdir(), paste0(private$databaseId, "-", Sys.getpid(), "-", exportTableName, ".csv")) @@ -134,11 +135,15 @@ ResultExportManager <- R6::R6Class( #' @param minCellCount Minimum cell count - reccomended that you set with #' options("ohdsi.minCellCount" = count) in all R projects. Default is 5 #' @param databaseId database identifier - required when exporting according to many specs + #' @param validateTypes Test if row values strictly conform to types - optional, not currently reccomended + #' outside of development initialize = function(tableSpecification, exportDir, minCellCount = getOption("ohdsi.minCellCount", default = 5), + validateTypes = FALSE, databaseId = NULL) { self$exportDir <- exportDir + self$validateTypes <- validateTypes # Check table spec is valid assertSpecificationColumns(colnames(tableSpecification)) private$tableSpecification <- tableSpecification @@ -298,11 +303,12 @@ ResultExportManager <- R6::R6Class( stop("Table not found in specifications") } - validRows <- self$checkRowTypes(rows, exportTableName) - if (!all(isTRUE(validRows))) { - stop(paste(validRows[!isTRUE(validRows)], collapse = "\n")) + if (self$validateTypes) { + validRows <- self$checkRowTypes(rows, exportTableName) + if (!all(isTRUE(validRows))) { + stop(paste(validRows[!isTRUE(validRows)], collapse = "\n")) + } } - # Convert < minCellCount to -minCellCount rows <- self$getMinColValues(rows, exportTableName) validPkeys <- self$checkPrimaryKeys(rows, exportTableName, invalidateCache = !append) diff --git a/man/ResultExportManager.Rd b/man/ResultExportManager.Rd index 3bfff4e..73c3a77 100644 --- a/man/ResultExportManager.Rd +++ b/man/ResultExportManager.Rd @@ -46,6 +46,7 @@ Create a class for exporting results from a study in a standard, consistend mann tableSpecification, exportDir, minCellCount = getOption("ohdsi.minCellCount", default = 5), + validateTypes = FALSE, databaseId = NULL )}\if{html}{\out{}} } @@ -60,8 +61,11 @@ Create a class for exporting results from a study in a standard, consistend mann \item{\code{minCellCount}}{Minimum cell count - reccomended that you set with options("ohdsi.minCellCount" = count) in all R projects. Default is 5} -\item{\code{databaseId}}{database identifier - required when exporting according to many specs +\item{\code{validateTypes}}{Test if row values strictly conform to types - optional, not currently reccomended +outside of development get table spec} + +\item{\code{databaseId}}{database identifier - required when exporting according to many specs} } \if{html}{\out{}} }