diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4af2166..7329336 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,7 @@ jobs: - postgres-image-a: 'postgres:13' postgres-image-b: 'postgres:14' postgres-auth: 'trust' - swift-image: 'swift:5.8-focal' + swift-image: 'swift:5.9-focal' - postgres-image-a: 'postgres:15' postgres-image-b: 'postgres:16' postgres-auth: 'md5' @@ -53,7 +53,7 @@ jobs: - postgres-image-a: 'postgres:15' postgres-image-b: 'postgres:16' postgres-auth: 'scram-sha-256' - swift-image: 'swiftlang/swift:nightly-6.0-jammy' + swift-image: 'swift:6.0-jammy' container: ${{ matrix.swift-image }} runs-on: ubuntu-latest services: @@ -89,8 +89,6 @@ jobs: fail-fast: false matrix: include: - - macos-version: macos-13 - xcode-version: '~14.3' - macos-version: macos-14 xcode-version: latest runs-on: ${{ matrix.macos-version }} diff --git a/Package.swift b/Package.swift index fcceab4..0560db0 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.8 +// swift-tools-version:5.9 import PackageDescription let package = Package( @@ -13,8 +13,8 @@ let package = Package( .library(name: "FluentPostgresDriver", targets: ["FluentPostgresDriver"]), ], dependencies: [ - .package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"), - .package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.4"), + .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), + .package(url: "https://github.com/vapor/fluent-kit.git", from: "1.49.0"), .package(url: "https://github.com/vapor/postgres-kit.git", from: "2.13.4"), ], targets: [ @@ -40,6 +40,9 @@ let package = Package( ) var swiftSettings: [SwiftSetting] { [ + .enableUpcomingFeature("ExistentialAny"), .enableUpcomingFeature("ConciseMagicFile"), .enableUpcomingFeature("ForwardTrailingClosures"), + .enableUpcomingFeature("DisableOutwardActorInference"), + .enableExperimentalFeature("StrictConcurrency=complete"), ] } diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift deleted file mode 100644 index e2305c3..0000000 --- a/Package@swift-5.9.swift +++ /dev/null @@ -1,48 +0,0 @@ -// swift-tools-version:5.9 -import PackageDescription - -let package = Package( - name: "fluent-postgres-driver", - platforms: [ - .macOS(.v10_15), - .iOS(.v13), - .watchOS(.v6), - .tvOS(.v13), - ], - products: [ - .library(name: "FluentPostgresDriver", targets: ["FluentPostgresDriver"]), - ], - dependencies: [ - .package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"), - .package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.4"), - .package(url: "https://github.com/vapor/postgres-kit.git", from: "2.13.4"), - ], - targets: [ - .target( - name: "FluentPostgresDriver", - dependencies: [ - .product(name: "AsyncKit", package: "async-kit"), - .product(name: "FluentKit", package: "fluent-kit"), - .product(name: "FluentSQL", package: "fluent-kit"), - .product(name: "PostgresKit", package: "postgres-kit"), - ], - swiftSettings: swiftSettings - ), - .testTarget( - name: "FluentPostgresDriverTests", - dependencies: [ - .product(name: "FluentBenchmark", package: "fluent-kit"), - .target(name: "FluentPostgresDriver"), - ], - swiftSettings: swiftSettings - ), - ] -) - -var swiftSettings: [SwiftSetting] { [ - .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("ConciseMagicFile"), - .enableUpcomingFeature("ForwardTrailingClosures"), - .enableUpcomingFeature("DisableOutwardActorInference"), - .enableExperimentalFeature("StrictConcurrency=complete"), -] } diff --git a/Sources/FluentPostgresDriver/FluentPostgresDriver.swift b/Sources/FluentPostgresDriver/FluentPostgresDriver.swift index d375eba..5b4d85c 100644 --- a/Sources/FluentPostgresDriver/FluentPostgresDriver.swift +++ b/Sources/FluentPostgresDriver/FluentPostgresDriver.swift @@ -27,4 +27,8 @@ struct _FluentPostgresDriver<E: PostgresJSONEncoder, D: PostgresJSONDecoder>: Da func shutdown() { try? self.pool.syncShutdownGracefully() } + + func shutdownAsync() async { + try? await self.pool.shutdownAsync() + } } diff --git a/Sources/FluentPostgresDriver/PostgresError+Database.swift b/Sources/FluentPostgresDriver/PostgresError+Database.swift index a214b6e..a2435ee 100644 --- a/Sources/FluentPostgresDriver/PostgresError+Database.swift +++ b/Sources/FluentPostgresDriver/PostgresError+Database.swift @@ -71,7 +71,8 @@ fileprivate extension PostgresError.Code { } } -extension PostgresError: DatabaseError { +// Used for DatabaseError conformance +extension PostgresError { public var isSyntaxError: Bool { self.code.isSyntaxError } public var isConnectionClosed: Bool { switch self { @@ -82,7 +83,8 @@ extension PostgresError: DatabaseError { public var isConstraintFailure: Bool { self.code.isConstraintFailure } } -extension PSQLError: DatabaseError { +// Used for DatabaseError conformance +extension PSQLError { public var isSyntaxError: Bool { switch self.code { case .server: return self.serverInfo?[.sqlState].map { PostgresError.Code(raw: $0).isSyntaxError } ?? false @@ -104,3 +106,11 @@ extension PSQLError: DatabaseError { } } } + +#if compiler(<6) +extension PostgresError: DatabaseError { } +extension PSQLError: DatabaseError { } +#else +extension PostgresError: @retroactive DatabaseError { } +extension PSQLError: @retroactive DatabaseError { } +#endif diff --git a/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift b/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift index 2297391..2501e4a 100644 --- a/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift +++ b/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift @@ -274,7 +274,7 @@ final class FluentPostgresDriverTests: XCTestCase { } override func tearDown() async throws { - self.dbs.shutdown() + await self.dbs.shutdownAsync() try await super.tearDown() } } diff --git a/Tests/FluentPostgresDriverTests/FluentPostgresTransactionControlTests.swift b/Tests/FluentPostgresDriverTests/FluentPostgresTransactionControlTests.swift index fa8f784..b33a45f 100644 --- a/Tests/FluentPostgresDriverTests/FluentPostgresTransactionControlTests.swift +++ b/Tests/FluentPostgresDriverTests/FluentPostgresTransactionControlTests.swift @@ -56,7 +56,7 @@ final class FluentPostgresTransactionControlTests: XCTestCase { override func tearDown() async throws { try await CreateTodo().revert(on: self.db) - self.dbs.shutdown() + await self.dbs.shutdownAsync() try await super.tearDown() }