Skip to content

Commit

Permalink
for "Invalid or closed connection" after gpkg_disconnect() #8
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Jun 16, 2023
1 parent 7ed3444 commit a189234
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/gpkg-connection.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ gpkg_disconnect.SQLiteConnection <- function(x) {
#' @param x A _geopackage_ object, a path to a GeoPackage or an _SQLiteConnection_
#' @return An SQLiteConnection with logical attribute `"disconnect"` indicating whether it should be disconnected after use.
#' @noRd
#' @imporFrom DBI dbIsValid
#' @keywords internal
.gpkg_connection_from_x <- function(x) {

Expand All @@ -91,6 +92,10 @@ gpkg_disconnect.SQLiteConnection <- function(x) {
disconnect <- FALSE
} else stop('`x` should be `geopackage` object, a path to a GeoPackage or an _SQLiteConnection_')

if (!DBI::dbIsValid(con)) {
con <- NULL
}

if (!is.null(con)) {
attr(con, 'disconnect') <- disconnect
}
Expand Down

0 comments on commit a189234

Please sign in to comment.