mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Add asserts about expected ends of transaction
This commit is contained in:
1 parent
dd4227303a
commit
cbbd0cb945
3 files changed
+15
-5
No files matched your search
@@ -361,7 +361,9 @@ extension DatabasePool: DatabaseReader {
|
||||
return try await readerPool.get { reader in
|
||||
try await reader.execute { db in
|
||||
defer {
|
||||
try? db.commit() // Ignore commit error
|
||||
// Ignore commit error, but make sure we leave the transaction
|
||||
try? db.commit()
|
||||
assert(!db.isInsideTransaction)
|
||||
}
|
||||
// The block isolation comes from the DEFERRED transaction.
|
||||
try db.beginTransaction(.deferred)
|
||||
@@ -385,7 +387,9 @@ extension DatabasePool: DatabaseReader {
|
||||
// Second async jump because that's how `Pool.async` has to be used.
|
||||
reader.async { db in
|
||||
defer {
|
||||
try? db.commit() // Ignore commit error
|
||||
// Ignore commit error, but make sure we leave the transaction
|
||||
try? db.commit()
|
||||
assert(!db.isInsideTransaction)
|
||||
releaseReader(.reuse)
|
||||
}
|
||||
do {
|
||||
@@ -547,7 +551,9 @@ extension DatabasePool: DatabaseReader {
|
||||
let (reader, releaseReader) = try readerPool.get()
|
||||
reader.async { db in
|
||||
defer {
|
||||
try? db.commit() // Ignore commit error
|
||||
// Ignore commit error, but make sure we leave the transaction
|
||||
try? db.commit()
|
||||
assert(!db.isInsideTransaction)
|
||||
releaseReader(.reuse)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -248,8 +248,9 @@ extension DatabaseQueue: DatabaseReader {
|
||||
) {
|
||||
writer.async { db in
|
||||
defer {
|
||||
// Ignore error because we can not notify it.
|
||||
// Ignore commit error (we can not notify it), but make sure we leave the transaction
|
||||
try? db.commit()
|
||||
assert(!db.isInsideTransaction)
|
||||
try? db.endReadOnly()
|
||||
}
|
||||
|
||||
@@ -296,8 +297,9 @@ extension DatabaseQueue: DatabaseReader {
|
||||
GRDBPrecondition(!db.isInsideTransaction, "must not be called from inside a transaction.")
|
||||
|
||||
defer {
|
||||
// Ignore error because we can not notify it.
|
||||
// Ignore commit error (we can not notify it), but make sure we leave the transaction
|
||||
try? db.commit()
|
||||
assert(!db.isInsideTransaction)
|
||||
try? db.endReadOnly()
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,9 @@ public final class DatabaseSnapshot {
|
||||
deinit {
|
||||
// Leave snapshot isolation
|
||||
reader.reentrantSync { db in
|
||||
// Ignore commit error (we can not notify it), but make sure we leave the transaction
|
||||
try? db.commit()
|
||||
assert(!db.isInsideTransaction)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user