diff --git a/DESCRIPTION b/DESCRIPTION index 3b59d1a..cc061d9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: mlr3db Title: Data Base Backend for 'mlr3' -Version: 0.5.1-9000 +Version: 0.5.2 Authors@R: person(given = "Michel", family = "Lang", @@ -21,7 +21,7 @@ Depends: mlr3 (>= 0.13.0), R (>= 3.1.0) Imports: - R6, + R6 (>= 2.4.0), backports, checkmate, data.table, diff --git a/NEWS.md b/NEWS.md index 85fb616..0830522 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ - Bugfix: `DataBackendDuckDB` calculated missing values incorrectly. - Compatibility with future versions of `dbplyr` (#35). +- Finalizers are now private # mlr3db 0.5.1 diff --git a/R/DataBackendDplyr.R b/R/DataBackendDplyr.R index 03a21ce..d7bc52d 100644 --- a/R/DataBackendDplyr.R +++ b/R/DataBackendDplyr.R @@ -120,16 +120,6 @@ DataBackendDplyr = R6Class("DataBackendDplyr", inherit = DataBackend, cloneable self$connector = assert_function(connector, args = character(), null.ok = TRUE) }, - #' @description - #' Finalizer which disconnects from the database. - #' This is called during garbage collection of the instance. - #' @return `logical(1)`, the return value of [DBI::dbDisconnect()]. - finalize = function() { - if (isTRUE(self$valid)) { - DBI::dbDisconnect(private$.data$src$con) - } - }, - #' @description #' Returns a slice of the data. #' Calls [dplyr::filter()] and [dplyr::select()] on the table and converts it to a [data.table::data.table()]. @@ -271,6 +261,16 @@ DataBackendDplyr = R6Class("DataBackendDplyr", inherit = DataBackend, cloneable ), private = list( + # @description + # Finalizer which disconnects from the database. + # This is called during garbage collection of the instance. + # @return `logical(1)`, the return value of [DBI::dbDisconnect()]. + finalize = function() { + if (isTRUE(self$valid)) { + DBI::dbDisconnect(private$.data$src$con) + } + }, + .calculate_hash = function() { private$.reconnect() calculate_hash(private$.data) diff --git a/R/DataBackendDuckDB.R b/R/DataBackendDuckDB.R index 03d0dd3..a043a6f 100644 --- a/R/DataBackendDuckDB.R +++ b/R/DataBackendDuckDB.R @@ -73,16 +73,6 @@ DataBackendDuckDB = R6Class("DataBackendDuckDB", inherit = DataBackend, cloneabl }, - #' @description - #' Finalizer which disconnects from the database. - #' This is called during garbage collection of the instance. - #' @return `logical(1)`, the return value of [DBI::dbDisconnect()]. - finalize = function() { - if (isTRUE(self$valid)) { - DBI::dbDisconnect(private$.data, shutdown = TRUE) - } - }, - #' @description #' Returns a slice of the data. #' @@ -243,6 +233,16 @@ DataBackendDuckDB = R6Class("DataBackendDuckDB", inherit = DataBackend, cloneabl ), private = list( + # @description + # Finalizer which disconnects from the database. + # This is called during garbage collection of the instance. + # @return `logical(1)`, the return value of [DBI::dbDisconnect()]. + finalize = function() { + if (isTRUE(self$valid)) { + DBI::dbDisconnect(private$.data, shutdown = TRUE) + } + }, + .calculate_hash = function() { private$.reconnect() calculate_hash(private$.data@driver@dbdir) diff --git a/man/DataBackendDplyr.Rd b/man/DataBackendDplyr.Rd index f972d15..5db4c26 100644 --- a/man/DataBackendDplyr.Rd +++ b/man/DataBackendDplyr.Rd @@ -94,7 +94,6 @@ Returns the result of \code{\link[DBI:dbIsValid]{DBI::dbIsValid()}} otherwise.} \subsection{Public methods}{ \itemize{ \item \href{#method-DataBackendDplyr-new}{\code{DataBackendDplyr$new()}} -\item \href{#method-DataBackendDplyr-finalize}{\code{DataBackendDplyr$finalize()}} \item \href{#method-DataBackendDplyr-data}{\code{DataBackendDplyr$data()}} \item \href{#method-DataBackendDplyr-head}{\code{DataBackendDplyr$head()}} \item \href{#method-DataBackendDplyr-distinct}{\code{DataBackendDplyr$distinct()}} @@ -160,20 +159,6 @@ To protect your credentials, it is recommended to use the \CRANpkg{secret} packa } } \if{html}{\out{