mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
TransactionObserverType methods are no longer optional.
This commit is contained in:
1 parent
0f698e1306
commit
b7147ba64c
4 files changed
+13
-18
No files matched your search
@@ -1,6 +1,13 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
## Next Release
|
||||
|
||||
**Breaking Change**
|
||||
|
||||
- The methods of protocol `TransactionObserverType` are no longer optional.
|
||||
|
||||
|
||||
## 0.27.0
|
||||
|
||||
Released November 4, 2015
|
||||
|
||||
@@ -636,21 +636,6 @@ public protocol TransactionObserverType : class {
|
||||
func databaseDidRollback(db: Database)
|
||||
}
|
||||
|
||||
/// Default implementations for TransactionObserverType methods.
|
||||
public extension TransactionObserverType {
|
||||
/// Default implementation does nothing.
|
||||
func databaseDidChangeWithEvent(event: DatabaseEvent) { }
|
||||
|
||||
/// Default implementation does nothing.
|
||||
func databaseWillCommit() throws { }
|
||||
|
||||
/// Default implementation does nothing.
|
||||
func databaseDidCommit(db: Database) { }
|
||||
|
||||
/// Default implementation does nothing.
|
||||
func databaseDidRollback(db: Database) { }
|
||||
}
|
||||
|
||||
|
||||
// =============================================================================
|
||||
// MARK: - DatabaseEvent
|
||||
|
||||
@@ -917,7 +917,7 @@ See [Column Values](#column-values) and [Value Queries](#value-queries) for more
|
||||
|
||||
**Prepared Statements** let you prepare an SQL query and execute it later, several times if you need, with different arguments.
|
||||
|
||||
There are two kinds to prepared statements: **select statements**, and **update statements**:
|
||||
There are two kinds of prepared statements: **select statements**, and **update statements**:
|
||||
|
||||
```swift
|
||||
try dbQueue.inTransaction { db in
|
||||
@@ -1229,7 +1229,7 @@ config.transactionObserver = MyObserver()
|
||||
let dbQueue = try DatabaseQueue(path: databasePath, configuration: config)
|
||||
```
|
||||
|
||||
All protocol callbacks are optional, and invoked on the database queue.
|
||||
Protocol callbacks are all invoked on the database queue.
|
||||
|
||||
**All database changes are notified** to databaseDidChangeWithEvent, inserts, updates and deletes, including indirect ones triggered by ON DELETE and ON UPDATE actions associated to [foreign keys](https://www.sqlite.org/foreignkeys.html#fk_actions).
|
||||
|
||||
@@ -1291,6 +1291,10 @@ class TableChangeObserver : NSObject, TransactionObserverType {
|
||||
changedTableNames.insert(event.tableName)
|
||||
}
|
||||
|
||||
func databaseWillCommit() throws {
|
||||
// Let go
|
||||
}
|
||||
|
||||
func databaseDidCommit(db: Database) {
|
||||
// Extract the names of changed tables, and reset until next
|
||||
// database event:
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
- [ ] Study custom SQL functions
|
||||
- [ ] Study custom collations
|
||||
- [ ] `IN (?)` sql snippet, with an array argument.
|
||||
- [ ] TransactionObserverType methods should not be optional. Non-optional methods force the user to adapt his code if the protocol eventually evolves. Requires TableChangeObserver sample code update.
|
||||
- [ ] Write sample code around NSFetchedResultsController: fetch and output a list of TableView sections & row differences.
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user