Skip to content

Commit 568d258

Browse files
committed
Disable copyFrom when using a Swift <6 compiler
Swift 5.10 does not support `#isolation`, which we use.
1 parent cb05b24 commit 568d258

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Sources/PostgresNIO/Connection/PostgresConnection+CopyFrom.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public struct PostgresCopyFromWriter: Sendable {
2929
}
3030
}
3131

32+
#if compiler(>=6.0)
3233
/// Send data for a `COPY ... FROM STDIN` operation to the backend.
3334
///
3435
/// - Throws: If an error occurs during the write of if the backend sent an `ErrorResponse` during the copy
@@ -96,6 +97,7 @@ public struct PostgresCopyFromWriter: Sendable {
9697
}
9798
}
9899
}
100+
#endif
99101
}
100102

101103
/// Specifies the format in which data is transferred to the backend in a COPY operation.
@@ -124,6 +126,7 @@ public struct PostgresCopyFromFormat: Sendable {
124126
}
125127
}
126128

129+
#if compiler(>=6.0)
127130
/// Create a `COPY ... FROM STDIN` query based on the given parameters.
128131
///
129132
/// An empty `columns` array signifies that no columns should be specified in the query and that all columns will be
@@ -221,3 +224,4 @@ extension PostgresConnection {
221224
try await writer.done()
222225
}
223226
}
227+
#endif

Tests/IntegrationTests/PSQLIntegrationTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ final class IntegrationTests: XCTestCase {
379379
}
380380
}
381381

382+
#if compiler(>=6.0)
382383
func testCopyIntoFrom() async throws {
383384
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 2)
384385
defer { XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully()) }
@@ -487,4 +488,5 @@ final class IntegrationTests: XCTestCase {
487488
XCTAssertEqual((error as? PSQLError)?.serverInfo?[.sqlState], "42601") // scanner_yyerror
488489
}
489490
}
491+
#endif
490492
}

Tests/PostgresNIOTests/New/PostgresConnectionTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ class PostgresConnectionTests: XCTestCase {
625625
}
626626
}
627627

628+
#if compiler(>=6.0)
628629
func testCopyFromSucceeds() async throws {
629630
try await assertCopyFrom { writer in
630631
try await writer.write(ByteBuffer(staticString: "1\tAlice\n"))
@@ -911,6 +912,7 @@ class PostgresConnectionTests: XCTestCase {
911912
try await connection.closeFuture.get()
912913
}
913914
}
915+
#endif
914916

915917
func makeTestConnectionWithAsyncTestingChannel() async throws -> (PostgresConnection, NIOAsyncTestingChannel) {
916918
let eventLoop = NIOAsyncTestingEventLoop()
@@ -944,6 +946,7 @@ class PostgresConnectionTests: XCTestCase {
944946
return (connection, channel)
945947
}
946948

949+
#if compiler(>=6.0)
947950
/// Validate the behavior of a `COPY FROM` query.
948951
///
949952
/// Also checks that the connection returns to an idle state after performing the copy and is capable
@@ -1011,6 +1014,7 @@ class PostgresConnectionTests: XCTestCase {
10111014
_ = try await channel.waitForUnpreparedRequest() // Await the dummy query messages
10121015
}
10131016
}
1017+
#endif
10141018
}
10151019

10161020
extension NIOAsyncTestingChannel {

0 commit comments

Comments
 (0)