Skip to content

Commit

Permalink
Use named savepoint in dbWriteTable.
Browse files Browse the repository at this point in the history
Closes #41
  • Loading branch information
hadley committed Sep 5, 2014
1 parent a028da4 commit f428333
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion NEWS
Expand Up @@ -21,7 +21,9 @@ Version 0.11.6.9000
FALSE. It will automatically add row names only if they are character,
not integer. When loading a file from disk, `dbWriteTable()` will no longer
attempt to guess the correct values for `row.names` and `header` - instead
supply them explicitly if the defaults are incorrect.
supply them explicitly if the defaults are incorrect. It now uses
named save points so `dbWriteTable()` can be nested inside other
transactions (#41).

- `dbBeginTransaction()` has been deprecated. Please use `dbBegin()` instead.
(#)
Expand Down
6 changes: 3 additions & 3 deletions R/ConnectionWrite.R
Expand Up @@ -42,8 +42,8 @@ setMethod("dbWriteTable", signature("SQLiteConnection", "character", "data.frame
if (overwrite && append)
stop("overwrite and append cannot both be TRUE", call. = FALSE)

dbBegin(conn)
on.exit(dbRollback(conn))
dbBegin(conn, "dbWriteTable")
on.exit(dbRollback(conn, "dbWriteTable"))

found <- dbExistsTable(conn, name)
if (found && !overwrite && !append) {
Expand Down Expand Up @@ -74,7 +74,7 @@ setMethod("dbWriteTable", signature("SQLiteConnection", "character", "data.frame
}

on.exit(NULL)
dbCommit(conn)
dbCommit(conn, "dbWriteTable")
TRUE
}
)
Expand Down

0 comments on commit f428333

Please sign in to comment.