mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
While writing SingletonRecordTest.swift, I tried the solution below, in order to turn a failed update into an insert:
func aroundUpdate(_ db: Database, columns: Set<String>, update: () throws -> PersistenceSuccess) throws {
do {
_ = try update()
} catch {
insert(db)
}
}
But this can't work. This `insert(db)` is unable to provide the information we need in `update()`: the result of the eventual RETURNING clause, and the PersistenceSuccess that contains the persisted PersistenceContainer.
So we now detect two misuses: 1) not calling the action method, and 2) not rethrowing the error of the action method.