diff --git a/R/context.R b/R/context.R index cba52b6a0..f08809799 100644 --- a/R/context.R +++ b/R/context.R @@ -23,7 +23,26 @@ #' @rdname context #' @importFrom methods is new #' @export -#' @example examples/make_context.R +#' @examplesIf requireNamespace("RSQLite", quietly = TRUE) +#' make_context( +#' new( +#' "DBIConnector", +#' .drv = RSQLite::SQLite(), +#' .conn_args = list(dbname = tempfile("DBItest", fileext = ".sqlite")) +#' ), +#' tweaks = tweaks( +#' constructor_relax_args = TRUE, +#' placeholder_pattern = c("?", "$1", "$name", ":name"), +#' date_cast = function(x) paste0("'", x, "'"), +#' time_cast = function(x) paste0("'", x, "'"), +#' timestamp_cast = function(x) paste0("'", x, "'"), +#' logical_return = function(x) as.integer(x), +#' date_typed = FALSE, +#' time_typed = FALSE, +#' timestamp_typed = FALSE +#' ), +#' default_skip = c("roundtrip_date", "roundtrip_timestamp") +#' ) make_context <- function(drv, connect_args = NULL, set_as_default = TRUE, tweaks = NULL, name = NULL, default_skip = NULL) { if (is.null(drv)) { diff --git a/examples/make_context.R b/examples/make_context.R deleted file mode 100644 index 3a5c55ae1..000000000 --- a/examples/make_context.R +++ /dev/null @@ -1,19 +0,0 @@ -make_context( - new( - "DBIConnector", - .drv = RSQLite::SQLite(), - .conn_args = list(dbname = tempfile("DBItest", fileext = ".sqlite")) - ), - tweaks = tweaks( - constructor_relax_args = TRUE, - placeholder_pattern = c("?", "$1", "$name", ":name"), - date_cast = function(x) paste0("'", x, "'"), - time_cast = function(x) paste0("'", x, "'"), - timestamp_cast = function(x) paste0("'", x, "'"), - logical_return = function(x) as.integer(x), - date_typed = FALSE, - time_typed = FALSE, - timestamp_typed = FALSE - ), - default_skip = c("roundtrip_date", "roundtrip_timestamp") -) diff --git a/man/context.Rd b/man/context.Rd index 02fcd1834..2efc8cd7b 100644 --- a/man/context.Rd +++ b/man/context.Rd @@ -49,6 +49,7 @@ to \code{\link[=test_all]{test_all()}} and other testing functions.} Create a test context, set and query the default context. } \examples{ +\dontshow{if (requireNamespace("RSQLite", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} make_context( new( "DBIConnector", @@ -68,4 +69,5 @@ make_context( ), default_skip = c("roundtrip_date", "roundtrip_timestamp") ) +\dontshow{\}) # examplesIf} }