R/dbRollback_AdbiConnection.R

Defines functions dbRollback_AdbiConnection

Documented in dbRollback_AdbiConnection

#' @rdname AdbiConnection-class
#' @inheritParams DBI::dbRollback
#' @usage NULL
dbRollback_AdbiConnection <- function(conn, ...) {

  if (...length()) {
    stop("Passing arguments as `...` is not supported", call. = FALSE)
  }

  state <- meta(conn, "transaction")

  if (is.null(state) || state == 0L) {
    stop("Cannot commit a transaction without transactional context.",
      call. = FALSE)
  }

  adbcdrivermanager::adbc_connection_rollback(conn@connection)

  adbcdrivermanager::adbc_connection_set_options(
    conn@connection,
    c(adbc.connection.autocommit = "true")
  )

  meta(conn, "transaction") <- state - 1L

  invisible(TRUE)
}

#' @rdname AdbiConnection-class
#' @export
setMethod("dbRollback", "AdbiConnection", dbRollback_AdbiConnection)

Try the adbi package in your browser

Any scripts or data that you put into this service are public.

adbi documentation built on May 29, 2024, 7:12 a.m.