mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
DatabaseReader and DatabaseWriter are no longer available for user types
- stop testing compatibility with user types - document that they are no longer available for user types (readme, changelog)
This commit is contained in:
1 parent
9c71356e3d
commit
08b103f5f5
3 files changed
+26
-30
No files matched your search
@@ -1,6 +1,13 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
## Next Version
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- The DatabaseReader and DatabaseWriter protocols have changed in a way that is compatible with your current code, except with your eventual custom types that implement those protocols. Only five types provided by GRDB adopt those propocols: DatabaseQueue, DatabasePool, DatabaseSnapshot, AnyDatabaseReader, and AnyDatabaseWriter. Expanding this set is no longer supported.
|
||||
|
||||
|
||||
## 3.4.0
|
||||
|
||||
Released October 8, 2018 • [diff](https://github.com/groue/GRDB.swift/compare/v3.3.1...v3.4.0)
|
||||
|
||||
@@ -7362,7 +7362,25 @@ These protocols provide a unified API that let you write generic code that targe
|
||||
- [FetchedRecordsController](#fetchedrecordscontroller)
|
||||
- [RxGRDB](http://github.com/RxSwiftCommunity/RxGRDB)
|
||||
|
||||
Caution: DatabaseReader and DatabaseWriter only provide the *smallest* common guarantees. They don't erase the differences between queues, pools, and snapshots. See for example [Differences between Database Queues and Pools](#differences-between-database-queues-and-pools).
|
||||
Only five types adopt those protocols: DatabaseQueue, DatabasePool, DatabaseSnapshot, AnyDatabaseReader, and AnyDatabaseWriter. Expanding this set is not supported: any future GRDB release may break your custom writers and readers, without notice.
|
||||
|
||||
DatabaseReader and DatabaseWriter provide the *smallest* common guarantees: they don't erase the differences between queues, pools, and snapshots. See for example [Differences between Database Queues and Pools](#differences-between-database-queues-and-pools).
|
||||
|
||||
However, you can easily prevent some parts of your application from writing in the database by giving them a DatabaseReader:
|
||||
|
||||
```swift
|
||||
// This class can read in the database, but can't write into it.
|
||||
class MyReadOnlyComponent {
|
||||
let reader: DatabaseReader
|
||||
|
||||
init(reader: DatabaseReader) {
|
||||
self.reader = reader
|
||||
}
|
||||
}
|
||||
|
||||
let dbQueue: DatabaseQueue = ...
|
||||
let component = MyReadOnlyComponent(reader: dbQueue)
|
||||
```
|
||||
|
||||
|
||||
### Unsafe Concurrency APIs
|
||||
|
||||
@@ -42,18 +42,6 @@ private class UserDatabaseAggregate2 : DatabaseAggregate {
|
||||
func finalize() throws -> DatabaseValueConvertible? { preconditionFailure() }
|
||||
}
|
||||
|
||||
// MARK: - DatabaseReader
|
||||
|
||||
private class UserDatabaseReader : DatabaseReader {
|
||||
func read<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func add(function: DatabaseFunction) { }
|
||||
func remove(function: DatabaseFunction) { }
|
||||
func add(collation: DatabaseCollation) { }
|
||||
func remove(collation: DatabaseCollation) { }
|
||||
}
|
||||
|
||||
// MARK: - DatabaseValueConvertible
|
||||
|
||||
private struct UserDatabaseValueConvertible1 : DatabaseValueConvertible {
|
||||
@@ -66,23 +54,6 @@ private class UserDatabaseValueConvertible2 : DatabaseValueConvertible {
|
||||
static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? { preconditionFailure() }
|
||||
}
|
||||
|
||||
// MARK: - DatabaseWriter
|
||||
|
||||
private class UserDatabaseWriter : DatabaseWriter {
|
||||
func read<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func unsafeRead<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func unsafeReentrantRead<T>(_ block: (Database) throws -> T) throws -> T { preconditionFailure() }
|
||||
func add(function: DatabaseFunction) { }
|
||||
func remove(function: DatabaseFunction) { }
|
||||
func add(collation: DatabaseCollation) { }
|
||||
func remove(collation: DatabaseCollation) { }
|
||||
func write<T>(_ block: (Database) throws -> T) rethrows -> T { preconditionFailure() }
|
||||
func writeWithoutTransaction<T>(_ block: (Database) throws -> T) rethrows -> T { preconditionFailure() }
|
||||
func unsafeReentrantWrite<T>(_ block: (Database) throws -> T) rethrows -> T { preconditionFailure() }
|
||||
func readFromCurrentState(_ block: @escaping (Database) -> Void) throws { preconditionFailure() }
|
||||
func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> Future<T> { preconditionFailure() }
|
||||
}
|
||||
|
||||
// MARK: - FTS5Tokenizer
|
||||
|
||||
#if SQLITE_ENABLE_FTS5
|
||||
|
||||
Reference in new issue
Block a user