Skip to content

Commit

Permalink
[BREAKING] Prefer any DatabaseReader and DatabaseWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Sep 21, 2024
1 parent 23842d8 commit 900180d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions GRDB/Core/DatabaseReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ extension DatabaseReader {
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or the
/// error thrown by `progress`.
public func backup(
to writer: some DatabaseWriter,
to writer: any DatabaseWriter,
pagesPerStep: CInt = -1,
progress: ((DatabaseBackupProgress) throws -> Void)? = nil)
throws
Expand Down Expand Up @@ -628,7 +628,7 @@ public final class AnyDatabaseReader {

/// Creates a new database reader that wraps and forwards operations
/// to `base`.
public init(_ base: some DatabaseReader) {
public init(_ base: any DatabaseReader) {
self.base = base
}
}
Expand Down
8 changes: 4 additions & 4 deletions GRDB/Core/DatabaseRegionObservation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension DatabaseRegionObservation {
/// modified the observed region.
/// - returns: A DatabaseCancellable that can stop the observation.
public func start(
in writer: some DatabaseWriter,
in writer: any DatabaseWriter,
onError: @escaping @Sendable (Error) -> Void,
onChange: @escaping @Sendable (Database) -> Void)
-> AnyDatabaseCancellable
Expand Down Expand Up @@ -139,7 +139,7 @@ extension DatabaseRegionObservation {
///
/// Do not reschedule the publisher with `receive(on:options:)` or any
/// `Publisher` method that schedules publisher elements.
public func publisher(in writer: some DatabaseWriter) -> DatabasePublishers.DatabaseRegion {
public func publisher(in writer: any DatabaseWriter) -> DatabasePublishers.DatabaseRegion {
DatabasePublishers.DatabaseRegion(self, in: writer)
}
}
Expand Down Expand Up @@ -195,7 +195,7 @@ extension DatabasePublishers {
let writer: any DatabaseWriter
let observation: DatabaseRegionObservation

init(_ observation: DatabaseRegionObservation, in writer: some DatabaseWriter) {
init(_ observation: DatabaseRegionObservation, in writer: any DatabaseWriter) {
self.writer = writer
self.observation = observation
}
Expand Down Expand Up @@ -247,7 +247,7 @@ extension DatabasePublishers {
private var lock = NSRecursiveLock() // Allow re-entrancy

init(
writer: some DatabaseWriter,
writer: any DatabaseWriter,
observation: DatabaseRegionObservation,
downstream: Downstream)
{
Expand Down
2 changes: 1 addition & 1 deletion GRDB/Core/DatabaseWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ public final class AnyDatabaseWriter {

/// Creates a new database reader that wraps and forwards operations
/// to `base`.
public init(_ base: some DatabaseWriter) {
public init(_ base: any DatabaseWriter) {
self.base = base
}
}
Expand Down
4 changes: 2 additions & 2 deletions GRDB/Documentation.docc/Extension/ValueObservation.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ When needed, you can help GRDB optimize observations and reduce database content

### Accessing Observed Values

- ``start(in:scheduling:onError:onChange:)-t62r``
- ``start(in:scheduling:onError:onChange:)-4mqbs``
- ``publisher(in:scheduling:)``
- ``start(in:scheduling:onError:onChange:)-10vwf``
- ``start(in:scheduling:onError:onChange:)-7z197``
- ``values(in:scheduling:bufferingPolicy:)``
- ``DatabaseCancellable``
- ``ValueObservationScheduler``
Expand Down
8 changes: 4 additions & 4 deletions GRDB/Migration/DatabaseMigrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public struct DatabaseMigrator: Sendable {
///
/// - parameter writer: A DatabaseWriter.
/// - throws: The error thrown by the first failed migration.
public func migrate(_ writer: some DatabaseWriter) throws {
public func migrate(_ writer: any DatabaseWriter) throws {
guard let lastMigration = _migrations.last else {
return
}
Expand All @@ -249,7 +249,7 @@ public struct DatabaseMigrator: Sendable {
/// - parameter writer: A DatabaseWriter.
/// - parameter targetIdentifier: A migration identifier.
/// - throws: The error thrown by the first failed migration.
public func migrate(_ writer: some DatabaseWriter, upTo targetIdentifier: String) throws {
public func migrate(_ writer: any DatabaseWriter, upTo targetIdentifier: String) throws {
try writer.barrierWriteWithoutTransaction { db in
try migrate(db, upTo: targetIdentifier)
}
Expand All @@ -263,7 +263,7 @@ public struct DatabaseMigrator: Sendable {
/// database, or the failure that prevented the migrations
/// from succeeding.
public func asyncMigrate(
_ writer: some DatabaseWriter,
_ writer: any DatabaseWriter,
completion: @escaping @Sendable (Result<Database, Error>) -> Void)
{
writer.asyncBarrierWriteWithoutTransaction { dbResult in
Expand Down Expand Up @@ -497,7 +497,7 @@ extension DatabaseMigrator {
/// where migrations should apply.
/// - parameter scheduler: A Combine Scheduler.
public func migratePublisher(
_ writer: some DatabaseWriter,
_ writer: any DatabaseWriter,
receiveOn scheduler: some Combine.Scheduler = DispatchQueue.main)
-> DatabasePublishers.Migrate
{
Expand Down
2 changes: 1 addition & 1 deletion GRDB/ValueObservation/SharedValueObservation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ extension ValueObservation {
/// - parameter extent: The extent of the shared database observation.
/// - returns: A `SharedValueObservation`
public func shared(
in reader: some DatabaseReader,
in reader: any DatabaseReader,
scheduling scheduler: some ValueObservationScheduler = .async(onQueue: .main),
extent: SharedValueObservationExtent = .whileObserved)
-> SharedValueObservation<Reducer.Value>
Expand Down
8 changes: 4 additions & 4 deletions GRDB/ValueObservation/ValueObservation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ extension ValueObservation: Refinable {
/// fresh value.
/// - returns: A DatabaseCancellable that can stop the observation.
@preconcurrency public func start(
in reader: some DatabaseReader,
in reader: any DatabaseReader,
scheduling scheduler: some ValueObservationScheduler,
onError: @escaping @Sendable (Error) -> Void,
onChange: @escaping @Sendable (Reducer.Value) -> Void)
Expand Down Expand Up @@ -180,7 +180,7 @@ extension ValueObservation: Refinable {
/// fresh value.
/// - returns: A DatabaseCancellable that can stop the observation.
@preconcurrency @MainActor public func start(
in reader: some DatabaseReader,
in reader: any DatabaseReader,
scheduling scheduler: some ValueObservationMainActorScheduler = .mainActor,
onError: @escaping @MainActor (Error) -> Void,
onChange: @escaping @MainActor (Reducer.Value) -> Void)
Expand Down Expand Up @@ -350,7 +350,7 @@ extension ValueObservation {
/// - parameter bufferingPolicy: see the documntation
/// of `AsyncThrowingStream`.
public func values(
in reader: some DatabaseReader,
in reader: any DatabaseReader,
scheduling scheduler: some ValueObservationScheduler = .task,
bufferingPolicy: AsyncValueObservation<Reducer.Value>.BufferingPolicy = .unbounded)
-> AsyncValueObservation<Reducer.Value>
Expand Down Expand Up @@ -486,7 +486,7 @@ extension ValueObservation {
/// values are dispatched asynchronously on the main dispatch queue.
/// - returns: A Combine publisher
public func publisher(
in reader: some DatabaseReader,
in reader: any DatabaseReader,
scheduling scheduler: some ValueObservationScheduler = .async(onQueue: .main))
-> DatabasePublishers.Value<Reducer.Value>
where Reducer: ValueReducer
Expand Down

0 comments on commit 900180d

Please sign in to comment.