Skip to content

Commit

Permalink
mfdb: Remove now-useless check_db_available
Browse files Browse the repository at this point in the history
All the examples that did use it are converted to DuckDB, which is
always available unlike a postgresql DB.
  • Loading branch information
lentinj committed Jun 16, 2021
1 parent 35064cd commit 6dcf8b4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ build:
R CMD build .

check: build
LANGUAGE="en" MFDB_FORCE_AVAILABLE="y" R --vanilla --slave CMD check "$(TARBALL)"
LANGUAGE="en" R --vanilla --slave CMD check "$(TARBALL)"

check-as-cran: build
MFDB_FORCE_AVAILABLE="y" R --vanilla --slave CMD check --as-cran "$(TARBALL)"
R --vanilla --slave CMD check --as-cran "$(TARBALL)"

wincheck: build
# See https://win-builder.r-project.org/ for more information
Expand Down
8 changes: 0 additions & 8 deletions R/mfdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
mfdb <- function(schema_name = "",
db_params = list(),
destroy_schema = FALSE,
check_db_available = FALSE,
save_temp_tables = FALSE) {
logger <- logging::getLogger('mfdb')
is_sqlite_dbname <- function (x) grepl("\\.sqlite3?$", x)
Expand Down Expand Up @@ -86,13 +85,6 @@ mfdb <- function(schema_name = "",
}
}

if (check_db_available) {
# Just check we managed to make a connection, for examples
if (nzchar(Sys.getenv('MFDB_FORCE_AVAILABLE'))) return (TRUE)
if (!("error" %in% class(db_connection))) return(TRUE)
return(FALSE)
}

if ("error" %in% class(db_connection)) {
stop("Could not connect to mf database: ", paste(db_connection$message, collapse = "\n"))
}
Expand Down
5 changes: 0 additions & 5 deletions man/mfdb.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
mfdb(schema_name,
db_params = list(),
destroy_schema = FALSE,
check_db_available = FALSE,
save_temp_tables = FALSE)

mfdb_disconnect(mdb)
Expand Down Expand Up @@ -60,10 +59,6 @@
Optional boolean. If true, any temporary tables will be made permanent
for later inspection.
}
\item{check_db_available}{
Optionabl boolean. If true, we will only check that the datbase
connection could be made. Mostly for use in examples.
}
\item{mdb}{
Database connection created by \code{mfdb()}.
}
Expand Down
7 changes: 0 additions & 7 deletions tests/test-mfdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,5 @@ ok_group("mfdb", {
ok(cmp(attempts, list(
list(host = "mfdb.rhi.hi.is", user = "polly", password = "ppwd", dbname = "dbname=mf sslmode=require", drv = pq_driver)
)), "Used special mfdb server parameters")

old_force <- Sys.getenv('MFDB_FORCE_AVAILABLE')
Sys.setenv(MFDB_FORCE_AVAILABLE = "")
ok(cmp(mfdb(check_db_available = T), FALSE), "Didn't error with check_db_available, just return FALSE")
Sys.setenv(MFDB_FORCE_AVAILABLE = "T")
ok(cmp(mfdb(check_db_available = T), TRUE), "MFDB_FORCE_AVAILABLE on, returned TRUE anyway")
Sys.setenv(MFDB_FORCE_AVAILABLE = old_force)
})
})

0 comments on commit 6dcf8b4

Please sign in to comment.