Database.isInsideTransaction

This commit is contained in:
Gwendal Roué committed 2016-04-23 09:56:47 +02:00
1 parent baf87f837a
commit 000bd1b200
3 files changed
+10 -1

No files matched your search

+4
View File
@@ -3,6 +3,10 @@ Release Notes
## Next Version
**New**
- `Database.isInsideTransaction` is true if database is currently inside a transaction.
**Fixed**
- FetchRequest.reverse() sorts by reversed RowID when no base ordering has been specified.
+6
View File
@@ -70,6 +70,9 @@ public final class Database {
return Int(sqlite3_total_changes(sqliteConnection))
}
/// True if the database connection is currently in a transaction.
public private(set) var isInsideTransaction: Bool = false
var lastErrorMessage: String? {
return String.fromCString(sqlite3_errmsg(sqliteConnection))
}
@@ -1034,14 +1037,17 @@ extension Database {
case .Exclusive:
try execute("BEGIN EXCLUSIVE TRANSACTION")
}
isInsideTransaction = true
}
private func rollback() throws {
try execute("ROLLBACK TRANSACTION")
isInsideTransaction = false
}
private func commit() throws {
try execute("COMMIT TRANSACTION")
isInsideTransaction = false
}
/// Add a transaction observer, so that it gets notified of all
-1
View File
@@ -1,4 +1,3 @@
- [ ] Add Database.isInTransaction
- [ ] Support for WITHOUT ROWID tables (check didInsertWithRowID and FetchRequest.reverse())
- [ ] What is the SQLITE_OPEN_WAL open flag?
- [ ] Read https://github.com/ccgus/fmdb/issues/262 and understand https://lists.apple.com/archives/cocoa-dev/2012/Aug/msg00527.html