Skip to content

Commit b5ca7d4

Browse files
committed
Publicize transaction function with array signature
Till Swift supports converting an array to a variadic list, we run into the problem where the compiler gives up on complex statements. Signed-off-by: Stephen Celis <[email protected]>
1 parent 3b96ca4 commit b5ca7d4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

SQLite Common/Database.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public final class Database {
220220
/// fail will short-circuit the rest and roll back the changes. A successful
221221
/// transaction will automatically be committed.
222222
///
223-
/// :param: statements Statements array to run in the transaction.
223+
/// :param: statements Statements to run in the transaction.
224224
///
225225
/// :returns: The last statement executed, successful or not.
226226
public func transaction(statements: [@autoclosure () -> Statement]) -> Statement {
@@ -241,7 +241,17 @@ public final class Database {
241241
return transaction(mode, statements)
242242
}
243243

244-
private func transaction(mode: TransactionMode, _ statements: [@autoclosure () -> Statement]) -> Statement {
244+
/// Runs a series of statements in a transaction. The first statement to
245+
/// fail will short-circuit the rest and roll back the changes. A successful
246+
/// transaction will automatically be committed.
247+
///
248+
/// :param: mode The mode in which the transaction will acquire a
249+
/// lock.
250+
///
251+
/// :param: statements Statements to run in the transaction.
252+
///
253+
/// :returns: The last statement executed, successful or not.
254+
public func transaction(mode: TransactionMode, _ statements: [@autoclosure () -> Statement]) -> Statement {
245255
var transaction = run("BEGIN \(mode.rawValue) TRANSACTION")
246256
// FIXME: rdar://15217242 // for statement in statements { transaction = transaction && statement() }
247257
for idx in 0..<statements.count { transaction = transaction && statements[idx]() }

0 commit comments

Comments
 (0)