@@ -13,13 +13,13 @@ public struct PostgresCopyFromWriter: Sendable {
1313 let promise = eventLoop. makePromise ( of: Void . self)
1414 self . channelHandler. value. checkBackendCanReceiveCopyData ( promise: promise)
1515 promise. futureResult. flatMap {
16- if eventLoop. inEventLoop {
17- return eventLoop. makeCompletedFuture ( withResultOf: {
16+ if self . eventLoop. inEventLoop {
17+ return self . eventLoop. makeCompletedFuture ( withResultOf: {
1818 try self . channelHandler. value. sendCopyData ( byteBuffer)
1919 } )
2020 } else {
21- let promise = eventLoop. makePromise ( of: Void . self)
22- eventLoop. execute {
21+ let promise = self . eventLoop. makePromise ( of: Void . self)
22+ self . eventLoop. execute {
2323 promise. completeWith ( Result ( catching: { try self . channelHandler. value. sendCopyData ( byteBuffer) } ) )
2424 }
2525 return promise. futureResult
@@ -31,7 +31,7 @@ public struct PostgresCopyFromWriter: Sendable {
3131
3232 /// Send data for a `COPY ... FROM STDIN` operation to the backend.
3333 ///
34- /// - Throws: If an error occurs during the write of if the backend sent an `ErrorResponse` during the copy
34+ /// - Throws: If an error occurs during the write of if the backend sent an `ErrorResponse` during the copy
3535 /// operation, eg. to indicate that a **previous** `write` call had an invalid format.
3636 public func write( _ byteBuffer: ByteBuffer , isolation: isolated ( any Actor ) ? = #isolation) async throws {
3737 // Check for cancellation. This is cheap and makes sure that we regularly check for cancellation in the
@@ -41,10 +41,10 @@ public struct PostgresCopyFromWriter: Sendable {
4141 try await withTaskCancellationHandler {
4242 do {
4343 try await withCheckedThrowingContinuation { ( continuation: CheckedContinuation < Void , any Error > ) in
44- if eventLoop. inEventLoop {
44+ if self . eventLoop. inEventLoop {
4545 writeAssumingInEventLoop ( byteBuffer, continuation)
4646 } else {
47- eventLoop. execute {
47+ self . eventLoop. execute {
4848 writeAssumingInEventLoop ( byteBuffer, continuation)
4949 }
5050 }
@@ -59,10 +59,10 @@ public struct PostgresCopyFromWriter: Sendable {
5959 throw error
6060 }
6161 } onCancel: {
62- if eventLoop. inEventLoop {
62+ if self . eventLoop. inEventLoop {
6363 self . channelHandler. value. cancel ( )
6464 } else {
65- eventLoop. execute {
65+ self . eventLoop. execute {
6666 self . channelHandler. value. cancel ( )
6767 }
6868 }
@@ -73,10 +73,10 @@ public struct PostgresCopyFromWriter: Sendable {
7373 /// the backend.
7474 func done( isolation: isolated ( any Actor ) ? = #isolation) async throws {
7575 try await withCheckedThrowingContinuation { ( continuation: CheckedContinuation < Void , any Error > ) in
76- if eventLoop. inEventLoop {
76+ if self . eventLoop. inEventLoop {
7777 self . channelHandler. value. sendCopyDone ( continuation: continuation)
7878 } else {
79- eventLoop. execute {
79+ self . eventLoop. execute {
8080 self . channelHandler. value. sendCopyDone ( continuation: continuation)
8181 }
8282 }
@@ -87,10 +87,10 @@ public struct PostgresCopyFromWriter: Sendable {
8787 /// the backend.
8888 func failed( error: any Error , isolation: isolated ( any Actor ) ? = #isolation) async throws {
8989 try await withCheckedThrowingContinuation { ( continuation: CheckedContinuation < Void , any Error > ) in
90- if eventLoop. inEventLoop {
90+ if self . eventLoop. inEventLoop {
9191 self . channelHandler. value. sendCopyFail ( message: " Client failed copy " , continuation: continuation)
9292 } else {
93- eventLoop. execute {
93+ self . eventLoop. execute {
9494 self . channelHandler. value. sendCopyFail ( message: " Client failed copy " , continuation: continuation)
9595 }
9696 }
@@ -99,7 +99,7 @@ public struct PostgresCopyFromWriter: Sendable {
9999}
100100
101101/// Specifies the format in which data is transferred to the backend in a COPY operation.
102- ///
102+ ///
103103/// See the Postgres documentation at https://www.postgresql.org/docs/current/sql-copy.html for the option's meanings
104104/// and their default values.
105105public struct PostgresCopyFromFormat : Sendable {
@@ -129,7 +129,7 @@ public struct PostgresCopyFromFormat: Sendable {
129129/// An empty `columns` array signifies that no columns should be specified in the query and that all columns will be
130130/// copied by the caller.
131131///
132- /// - Important : The table and column names are inserted into the `COPY FROM` query as passed and might thus be
132+ /// - Warning : The table and column names are inserted into the `COPY FROM` query as passed and might thus be
133133/// susceptible to SQL injection. Ensure no untrusted data is contained in these strings.
134134private func buildCopyFromQuery(
135135 table: String ,
@@ -141,7 +141,7 @@ private func buildCopyFromQuery(
141141 """
142142 if !columns. isEmpty {
143143 query += " ( "
144- query += columns. map { #"""# + $0 . description + #" ""# } . joined ( separator: " , " )
144+ query += columns. map { #"" \#( $0 ) ""# } . joined ( separator: " , " )
145145 query += " ) "
146146 }
147147 query += " FROM STDIN "
@@ -207,9 +207,9 @@ extension PostgresConnection {
207207 // threw instead of the one that got relayed back, so it's better to ignore the error here.
208208 // - The backend sent us an `ErrorResponse` during the copy, eg. because of an invalid format. This puts
209209 // the `ExtendedQueryStateMachine` in the error state. Trying to send a `CopyFail` will throw but trigger
210- // a `Sync` that takes the backend out of copy mode. If `writeData` threw the error from from the
211- // `PostgresCopyFromWriter.write` call, `writer.failed` will throw with the same error, so it doesn't
212- // matter that we ignore the error here. If the user threw some other error, it's better to honor the
210+ // a `Sync` that takes the backend out of copy mode. If `writeData` threw the error from from the
211+ // `PostgresCopyFromWriter.write` call, `writer.failed` will throw with the same error, so it doesn't
212+ // matter that we ignore the error here. If the user threw some other error, it's better to honor the
213213 // user's error.
214214 try ? await writer. failed ( error: error)
215215
0 commit comments