Skip to content

Commit

Permalink
Merge pull request #1634 from groue/dev/GRDB7-bump-requirements
Browse files Browse the repository at this point in the history
GRDB 7: Bump requirements (again)
  • Loading branch information
groue authored Sep 21, 2024
2 parents f794d98 + 46e1561 commit 23842d8
Show file tree
Hide file tree
Showing 88 changed files with 554 additions and 1,083 deletions.
6 changes: 3 additions & 3 deletions GRDB.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Pod::Spec.new do |s|
s.module_name = 'GRDB'

s.swift_versions = ['5.10']
s.ios.deployment_target = '12.0'
s.osx.deployment_target = '10.13'
s.ios.deployment_target = '13.0'
s.osx.deployment_target = '10.15'
s.watchos.deployment_target = '7.0'
s.tvos.deployment_target = '12.0'
s.tvos.deployment_target = '13.0'
s.default_subspec = 'standard'

s.subspec 'standard' do |ss|
Expand Down
30 changes: 8 additions & 22 deletions GRDB/Core/Database+Statements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -492,17 +492,15 @@ extension Database {
// and throws the user-provided cancelled commit error.
try observationBroker?.statementDidFail(statement)

if #available(iOS 13, macOS 10.15, tvOS 13, *) {
switch ResultCode(rawValue: resultCode) {
case .SQLITE_INTERRUPT, .SQLITE_ABORT:
if suspensionMutex.load().isCancelled {
// The only error that a user sees when a Task is cancelled
// is CancellationError.
throw CancellationError()
}
default:
break
switch ResultCode(rawValue: resultCode) {
case .SQLITE_INTERRUPT, .SQLITE_ABORT:
if suspensionMutex.load().isCancelled {
// The only error that a user sees when a Task is cancelled
// is CancellationError.
throw CancellationError()
}
default:
break
}

// Throw statement failure
Expand Down Expand Up @@ -554,19 +552,7 @@ struct StatementCache {
// > time and probably reused many times.
//
// This looks like a perfect match for cached statements.
//
// However SQLITE_PREPARE_PERSISTENT was only introduced in
// SQLite 3.20.0 http://www.sqlite.org/changes.html#version_3_20
#if GRDBCUSTOMSQLITE || GRDBCIPHER
let statement = try db.makeStatement(sql: sql, prepFlags: CUnsignedInt(SQLITE_PREPARE_PERSISTENT))
#else
let statement: Statement
if #available(macOS 10.14, *) { // SQLite 3.20+
statement = try db.makeStatement(sql: sql, prepFlags: CUnsignedInt(SQLITE_PREPARE_PERSISTENT))
} else {
statement = try db.makeStatement(sql: sql)
}
#endif
statements[sql] = statement
return statement
}
Expand Down
9 changes: 1 addition & 8 deletions GRDB/Core/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,6 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// will throw `CancellationError`, until `uncancel()` is called.
///
/// This method can be called from any thread.
@available(iOS 13, macOS 10.15, tvOS 13, *)
func cancel() {
let needsInterrupt = suspensionMutex.withLock { suspension in
if suspension.isCancelled {
Expand All @@ -1216,7 +1215,6 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
}

/// Undo `cancel()`.
@available(iOS 13, macOS 10.15, tvOS 13, *)
func uncancel() {
suspensionMutex.withLock {
$0.isCancelled = false
Expand Down Expand Up @@ -1320,12 +1318,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
break

case .cancel:
if #available(iOS 13, macOS 10.15, tvOS 13, *) {
throw CancellationError()
} else {
// GRDB bug: cancellation is a Swift concurrency feature
fatalError("Can't cancel without support for Swift concurrency")
}
throw CancellationError()

case .abort:
// Attempt at releasing an eventual lock with ROLLBACk,
Expand Down
4 changes: 0 additions & 4 deletions GRDB/Core/DatabasePool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ extension DatabasePool: DatabaseReader {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func read<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down Expand Up @@ -436,7 +435,6 @@ extension DatabasePool: DatabaseReader {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func unsafeRead<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down Expand Up @@ -803,7 +801,6 @@ extension DatabasePool: DatabaseWriter {
try writer.sync(updates)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func writeWithoutTransaction<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand All @@ -820,7 +817,6 @@ extension DatabasePool: DatabaseWriter {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func barrierWriteWithoutTransaction<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down
1 change: 0 additions & 1 deletion GRDB/Core/DatabasePublishers.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if canImport(Combine)
/// A namespace for database Combine publishers.
@available(iOS 13, macOS 10.15, tvOS 13, *)
public enum DatabasePublishers { }
#endif
4 changes: 0 additions & 4 deletions GRDB/Core/DatabaseQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ extension DatabaseQueue: DatabaseReader {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func read<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down Expand Up @@ -272,7 +271,6 @@ extension DatabaseQueue: DatabaseReader {
try writer.sync(value)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func unsafeRead<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down Expand Up @@ -386,7 +384,6 @@ extension DatabaseQueue: DatabaseWriter {
try writer.sync(updates)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func writeWithoutTransaction<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand All @@ -398,7 +395,6 @@ extension DatabaseQueue: DatabaseWriter {
try writer.sync(updates)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func barrierWriteWithoutTransaction<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down
7 changes: 0 additions & 7 deletions GRDB/Core/DatabaseReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public protocol DatabaseReader: AnyObject, Sendable {
/// - throws: Any ``DatabaseError`` that happens while establishing the
/// database access, or the error thrown by `value`, or
/// `CancellationError` if the task is cancelled.
@available(iOS 13, macOS 10.15, tvOS 13, *)
func read<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T
Expand Down Expand Up @@ -323,7 +322,6 @@ public protocol DatabaseReader: AnyObject, Sendable {
/// - throws: Any ``DatabaseError`` that happens while establishing the
/// database access, or the error thrown by `value`, or
/// `CancellationError` if the task is cancelled.
@available(iOS 13, macOS 10.15, tvOS 13, *)
func unsafeRead<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T
Expand Down Expand Up @@ -535,7 +533,6 @@ extension DatabaseReader {
///
/// - parameter scheduler: A Combine Scheduler.
/// - parameter value: A closure which accesses the database.
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func readPublisher<Output>(
receiveOn scheduler: some Combine.Scheduler = DispatchQueue.main,
value: @escaping @Sendable (Database) throws -> Output
Expand All @@ -550,7 +547,6 @@ extension DatabaseReader {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
extension DatabasePublishers {
/// A publisher that reads from the database.
///
Expand All @@ -569,7 +565,6 @@ extension DatabasePublishers {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
extension Publisher where Failure == Error {
fileprivate func eraseToReadPublisher() -> DatabasePublishers.Read<Output> {
.init(upstream: eraseToAnyPublisher())
Expand Down Expand Up @@ -660,7 +655,6 @@ extension AnyDatabaseReader: DatabaseReader {
try base.read(value)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func read<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand All @@ -678,7 +672,6 @@ extension AnyDatabaseReader: DatabaseReader {
try base.unsafeRead(value)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func unsafeRead<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down
3 changes: 0 additions & 3 deletions GRDB/Core/DatabaseRegionObservation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ extension DatabaseRegionObservation {
}

#if canImport(Combine)
@available(iOS 13, macOS 10.15, tvOS 13, *)
extension DatabaseRegionObservation {
// MARK: - Publishing Impactful Transactions

Expand All @@ -140,7 +139,6 @@ extension DatabaseRegionObservation {
///
/// Do not reschedule the publisher with `receive(on:options:)` or any
/// `Publisher` method that schedules publisher elements.
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func publisher(in writer: some DatabaseWriter) -> DatabasePublishers.DatabaseRegion {
DatabasePublishers.DatabaseRegion(self, in: writer)
}
Expand Down Expand Up @@ -186,7 +184,6 @@ private class DatabaseRegionObserver: TransactionObserver {
}

#if canImport(Combine)
@available(iOS 13, macOS 10.15, tvOS 13, *)
extension DatabasePublishers {
/// A publisher that tracks transactions that modify a database region.
///
Expand Down
2 changes: 0 additions & 2 deletions GRDB/Core/DatabaseSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
try reader.sync(block)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func read<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand All @@ -173,7 +172,6 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
// We can't provide this as a default implementation in
// `DatabaseSnapshotReader`, because of
// <https://github.com/apple/swift/issues/74469>.
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func unsafeRead<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down
2 changes: 0 additions & 2 deletions GRDB/Core/DatabaseSnapshotPool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func read<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down Expand Up @@ -353,7 +352,6 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
// We can't provide this as a default implementation in
// `DatabaseSnapshotReader`, because of
// <https://github.com/apple/swift/issues/74469>.
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func unsafeRead<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down
15 changes: 0 additions & 15 deletions GRDB/Core/DatabaseWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ public protocol DatabaseWriter: DatabaseReader {
/// - throws: Any ``DatabaseError`` that happens while establishing the
/// database access, or the error thrown by `updates`, or
/// `CancellationError` if the task is cancelled.
@available(iOS 13, macOS 10.15, tvOS 13, *)
func writeWithoutTransaction<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T
Expand Down Expand Up @@ -217,7 +216,6 @@ public protocol DatabaseWriter: DatabaseReader {
/// - throws: Any ``DatabaseError`` that happens while establishing the
/// database access, or the error thrown by `updates`, or
/// `CancellationError` if the task is cancelled.
@available(iOS 13, macOS 10.15, tvOS 13, *)
func barrierWriteWithoutTransaction<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T
Expand Down Expand Up @@ -649,7 +647,6 @@ extension DatabaseWriter {
/// - throws: Any ``DatabaseError`` that happens while establishing the
/// database access, or the error thrown by `updates`, or
/// `CancellationError` if the task is cancelled.
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func write<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand All @@ -666,7 +663,6 @@ extension DatabaseWriter {
/// Erase the database: delete all content, drop all tables, etc.
///
/// - note: [**🔥 EXPERIMENTAL**](https://github.com/groue/GRDB.swift/blob/master/README.md#what-are-experimental-features)
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func erase() async throws {
try await writeWithoutTransaction { try $0.erase() }
}
Expand All @@ -677,7 +673,6 @@ extension DatabaseWriter {
/// - note: [**🔥 EXPERIMENTAL**](https://github.com/groue/GRDB.swift/blob/master/README.md#what-are-experimental-features)
///
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html>
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func vacuum() async throws {
try await writeWithoutTransaction { try $0.execute(sql: "VACUUM") }
}
Expand All @@ -694,7 +689,6 @@ extension DatabaseWriter {
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html#vacuuminto>
///
/// - Parameter filePath: file path for new database
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func vacuum(into filePath: String) async throws {
try await writeWithoutTransaction {
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
Expand All @@ -709,7 +703,6 @@ extension DatabaseWriter {
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html#vacuuminto>
///
/// - Parameter filePath: file path for new database
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func vacuum(into filePath: String) async throws {
try await writeWithoutTransaction {
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
Expand Down Expand Up @@ -754,7 +747,6 @@ extension DatabaseWriter {
///
/// - parameter scheduler: A Combine Scheduler.
/// - parameter updates: A closure which accesses the database.
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func writePublisher<Output>(
receiveOn scheduler: some Combine.Scheduler = DispatchQueue.main,
updates: @escaping @Sendable (Database) throws -> Output
Expand Down Expand Up @@ -818,7 +810,6 @@ extension DatabaseWriter {
/// - parameter scheduler: A Combine Scheduler.
/// - parameter updates: A closure which writes in the database.
/// - parameter value: A closure which reads from the database.
@available(iOS 13, macOS 10.15, tvOS 13, *)
public func writePublisher<T: Sendable, Output>(
receiveOn scheduler: some Combine.Scheduler = DispatchQueue.main,
updates: @escaping @Sendable (Database) throws -> T,
Expand Down Expand Up @@ -848,7 +839,6 @@ extension DatabaseWriter {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
extension DatabasePublishers {
/// A publisher that writes into the database.
///
Expand All @@ -867,7 +857,6 @@ extension DatabasePublishers {
}
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
extension Publisher where Failure == Error {
fileprivate func eraseToWritePublisher() -> DatabasePublishers.Write<Output> {
.init(upstream: self.eraseToAnyPublisher())
Expand Down Expand Up @@ -911,7 +900,6 @@ extension AnyDatabaseWriter: DatabaseReader {
try base.read(value)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func read<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand All @@ -929,7 +917,6 @@ extension AnyDatabaseWriter: DatabaseReader {
try base.unsafeRead(value)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func unsafeRead<T: Sendable>(
_ value: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down Expand Up @@ -964,7 +951,6 @@ extension AnyDatabaseWriter: DatabaseWriter {
try base.writeWithoutTransaction(updates)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func writeWithoutTransaction<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand All @@ -976,7 +962,6 @@ extension AnyDatabaseWriter: DatabaseWriter {
try base.barrierWriteWithoutTransaction(updates)
}

@available(iOS 13, macOS 10.15, tvOS 13, *)
public func barrierWriteWithoutTransaction<T: Sendable>(
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T {
Expand Down
Loading

0 comments on commit 23842d8

Please sign in to comment.