Skip to content

Commit 21d705e

Browse files
committed
Add/publicize array savepoint functions
Signed-off-by: Stephen Celis <[email protected]>
1 parent b5ca7d4 commit 21d705e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

SQLite Common/Database.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,17 @@ public final class Database {
272272
///
273273
/// :returns: The last statement executed, successful or not.
274274
public func savepoint(statements: (@autoclosure () -> Statement)...) -> Statement {
275+
return savepoint(statements)
276+
}
277+
278+
/// Runs a series of statements in a new savepoint. The first statement to
279+
/// fail will short-circuit the rest and roll back the changes. A successful
280+
/// savepoint will automatically be committed.
281+
///
282+
/// :param: statements Statements to run in the savepoint.
283+
///
284+
/// :returns: The last statement executed, successful or not.
285+
public func savepoint(statements: [@autoclosure () -> Statement]) -> Statement {
275286
let transaction = savepoint("\(++saveName)", statements)
276287
--saveName
277288
return transaction
@@ -290,7 +301,16 @@ public final class Database {
290301
return savepoint(name, statements)
291302
}
292303

293-
private func savepoint(name: String, _ statements: [@autoclosure () -> Statement]) -> Statement {
304+
/// Runs a series of statements in a new savepoint. The first statement to
305+
/// fail will short-circuit the rest and roll back the changes. A successful
306+
/// savepoint will automatically be committed.
307+
///
308+
/// :param: name The name of the savepoint.
309+
///
310+
/// :param: statements Statements to run in the savepoint.
311+
///
312+
/// :returns: The last statement executed, successful or not.
313+
public func savepoint(name: String, _ statements: [@autoclosure () -> Statement]) -> Statement {
294314
let quotedName = quote(literal: name)
295315
var savepoint = run("SAVEPOINT \(quotedName)")
296316
// FIXME: rdar://15217242 // for statement in statements { savepoint = savepoint && statement() }

0 commit comments

Comments
 (0)