Skip to content

Commit

Permalink
stronger inline version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Herold committed Nov 7, 2024
1 parent 82284be commit 8255c2a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ Imports:
V8,
R.utils
Suggests:
sofa (>= 0.3.0),
elastic (>= 1.0.0),
mongolite (>= 1.6),
RSQLite (>= 2.3.7.9014),
duckdb (>= 1.1.0),
sofa,
elastic,
mongolite,
RSQLite,
duckdb,
RPostgres,
testthat,
withr,
callr,
webfakes (>= 1.2.0),
webfakes,
knitr,
rmarkdown,
tibble
Expand Down
10 changes: 5 additions & 5 deletions R/src_sqlite.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
#' print(con)
#' }
#'
src_sqlite <- function(dbname = ":memory:",
...) {
src_sqlite <- function(dbname = ":memory:", ...) {

# check minimum version
featUuid <- pkgNeeded("RSQLite", "2.3.7.9000")
pkgNeeded("RSQLite", "2.3.6")

# open connection
con <- DBI::dbConnect(
drv = RSQLite::SQLite(),
Expand All @@ -40,7 +39,8 @@ src_sqlite <- function(dbname = ":memory:",
# enable regular expressions
RSQLite::initRegExp(db = con)

# enable uuid and lines
# enable uuid for csv lines import
featUuid <- pkgNeeded("RSQLite", "2.3.7.9014", FALSE)
if (featUuid) RSQLite::initExtension(db = con, extension = "uuid")

# set timeout for concurrency to 10s
Expand Down
17 changes: 14 additions & 3 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ assert <- function(x, y) {
#' @keywords internal
#' @noRd
#'
pkgNeeded <- function(pkg, minV) {
pkgNeeded <- function(pkg, minV, minVneeded = TRUE) {

if (!requireNamespace(pkg, quietly = TRUE)) {
stop(
Expand All @@ -71,8 +71,19 @@ pkgNeeded <- function(pkg, minV) {
)
}

return(utils::packageVersion(pkg) >=
package_version(minV))
minVavailable <- utils::packageVersion(pkg) >=
package_version(minV)

if (!minVavailable && minVneeded) {
stop(
"Package '", pkg,
"' must be updated to at least version ",
minV, " to use this function.",
call. = FALSE
)
}

return(minVavailable)

}

Expand Down

0 comments on commit 8255c2a

Please sign in to comment.