Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override getConnection in PooledConnectionHandler so it returns the c… #63

Closed
wants to merge 11 commits into from
10 changes: 7 additions & 3 deletions R/PooledConnectionHandler.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ PooledConnectionHandler <- R6::R6Class(
#' get dbms
#' @description Get the dbms type of the connection
dbms = function() {
conn <- pool::poolCheckout(self$getConnection())
conn <- self$getConnection()
on.exit(pool::poolReturn(conn))
DatabaseConnector::dbms(conn)
},

getConnection = function() {
pool::poolCheckout(super$getConnection())
},

#' Close Connection
#' @description
#' Overrides ConnectionHandler Call
Expand All @@ -163,7 +167,7 @@ PooledConnectionHandler <- R6::R6Class(
#' @param sql sql query string
#' @param snakeCaseToCamelCase (Optional) Boolean. return the results columns in camel case (default)
queryFunction = function(sql, snakeCaseToCamelCase = self$snakeCaseToCamelCase) {
conn <- pool::poolCheckout(self$getConnection())
conn <- self$getConnection()
on.exit(pool::poolReturn(conn))
data <- DatabaseConnector::dbGetQuery(conn, sql, translate = FALSE)
if (snakeCaseToCamelCase) {
Expand All @@ -179,7 +183,7 @@ PooledConnectionHandler <- R6::R6Class(
#' Overrides ConnectionHandler Call. Does not translate or render sql.
#' @param sql sql query string
executeFunction = function(sql) {
conn <- pool::poolCheckout(self$getConnection())
conn <- self$getConnection()
on.exit(pool::poolReturn(conn))
DatabaseConnector::dbExecute(conn, sql, translate = FALSE)
}
Expand Down
Loading