diff --git a/DESCRIPTION b/DESCRIPTION index cd01fc1..a0f91e7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,6 @@ Suggests: RSQLite, duckdb, RPostgres, - withr, knitr, rmarkdown, keyring, diff --git a/R/PooledConnectionHandler.R b/R/PooledConnectionHandler.R index 60c014f..b850552 100644 --- a/R/PooledConnectionHandler.R +++ b/R/PooledConnectionHandler.R @@ -143,8 +143,8 @@ PooledConnectionHandler <- R6::R6Class( #' Returns a connection from the pool #' When the desired frame exits, the connection will be returned to the pool #' @param .deferedFrame defaults to the parent frame of the calling block. - getConnection = function(.deferedFrame = parent.frame()) { - conn <- pool::poolCheckout(self$getConnection()) + getConnection = function(.deferedFrame = parent.frame(n = 2)) { + conn <- pool::poolCheckout(super$getConnection()) withr::defer(pool::poolReturn(conn), envir = .deferedFrame) return(conn) }, diff --git a/tests/testthat/test-ConnectionHandler.R b/tests/testthat/test-ConnectionHandler.R index aa84777..8b79b49 100644 --- a/tests/testthat/test-ConnectionHandler.R +++ b/tests/testthat/test-ConnectionHandler.R @@ -85,6 +85,6 @@ test_that("Database Connector Class works", { test_that("Pooled connector Class works", { genericTests(PooledConnectionHandler, classes = c("PooledConnectionHandler", "ConnectionHandler"), - connectionClass = "Pool" + connectionClass = "DatabaseConnectorDbiConnection" ) })