diff --git a/Sources/MySQLKit/MySQLConnectionSource.swift b/Sources/MySQLKit/MySQLConnectionSource.swift index 0c88113..ba3c111 100644 --- a/Sources/MySQLKit/MySQLConnectionSource.swift +++ b/Sources/MySQLKit/MySQLConnectionSource.swift @@ -37,4 +37,4 @@ public struct MySQLConnectionSource: ConnectionPoolSource { } } -extension MySQLConnection: ConnectionPoolItem {} +extension MySQLNIO.MySQLConnection: AsyncKit.ConnectionPoolItem {} // Fully qualifying the type names implies @retroactive diff --git a/Sources/MySQLKit/MySQLDataDecoder.swift b/Sources/MySQLKit/MySQLDataDecoder.swift index f5b7799..2afc754 100644 --- a/Sources/MySQLKit/MySQLDataDecoder.swift +++ b/Sources/MySQLKit/MySQLDataDecoder.swift @@ -8,15 +8,18 @@ import NIOFoundationCompat /// Types which conform to `MySQLDataConvertible` are converted directly to the requested type. For other types, /// an attempt is made to interpret the database value as JSON and decode the type from it. public struct MySQLDataDecoder: Sendable { + /// A wrapper to silence `Sendable` warnings for `JSONDecoder` when not on macOS. + struct FakeSendable: @unchecked Sendable { let value: T } + /// The `JSONDecoder` used for decoding values that can't be directly converted. - let json: JSONDecoder + let json: FakeSendable /// Initialize a ``MySQLDataDecoder`` with a JSON decoder. /// /// - Parameter json: A `JSONDecoder` to use for decoding types that can't be directly converted. Defaults /// to an unconfigured decoder. public init(json: JSONDecoder = .init()) { - self.json = json + self.json = .init(value: json) } /// Convert the given `MySQLData` into a value of type `T`, if possible. @@ -43,7 +46,7 @@ public struct MySQLDataDecoder: Sendable { return try T.init(from: NestedSingleValueUnwrappingDecoder(decoder: self, data: data)) } catch is SQLCodingError where [.blob, .json, .longBlob, .mediumBlob, .string, .tinyBlob, .varString, .varchar].contains(data.type) { // Couldn't unwrap it, but it's textual. Try decoding as JSON as a last ditch effort. - return try self.json.decode(T.self, from: data.buffer ?? .init()) + return try self.json.value.decode(T.self, from: data.buffer ?? .init()) } } } diff --git a/Sources/MySQLKit/MySQLDataEncoder.swift b/Sources/MySQLKit/MySQLDataEncoder.swift index 00266e7..29e07d7 100644 --- a/Sources/MySQLKit/MySQLDataEncoder.swift +++ b/Sources/MySQLKit/MySQLDataEncoder.swift @@ -8,15 +8,18 @@ import NIOFoundationCompat /// Types which conform to `MySQLDataConvertible` are converted directly to `MySQLData`. Other types are /// encoded as JSON and sent to the database as text. public struct MySQLDataEncoder: Sendable { + /// A wrapper to silence `Sendable` warnings for `JSONEncoder` when not on macOS. + struct FakeSendable: @unchecked Sendable { let value: T } + /// The `JSONEncoder` used for encoding values that can't be directly converted. - let json: JSONEncoder + let json: FakeSendable /// Initialize a ``MySQLDataEncoder`` with a JSON encoder. /// /// - Parameter json: A `JSONEncoder` to use for encoding types that can't be directly converted. Defaults /// to an unconfigured encoder. public init(json: JSONEncoder = .init()) { - self.json = json + self.json = .init(value: json) } /// Convert the given `Encodable` value to a `MySQLData` value, if possible. @@ -42,7 +45,7 @@ public struct MySQLDataEncoder: Sendable { return MySQLData( type: .string, format: .text, - buffer: try self.json.encodeAsByteBuffer(value, allocator: .init()), + buffer: try self.json.value.encodeAsByteBuffer(value, allocator: .init()), isUnsigned: true ) } @@ -165,3 +168,6 @@ public struct MySQLDataEncoder: Sendable { } } } + +/// This conformance suppresses a slew of spurious warnings in some build environments. +extension MySQLNIO.MySQLProtocol.DataType: @unchecked Swift.Sendable {} // Fully qualifying the type names implies @retroactive diff --git a/Sources/MySQLKit/MySQLRow+SQL.swift b/Sources/MySQLKit/MySQLRow+SQL.swift index 1840f92..a0b7568 100644 --- a/Sources/MySQLKit/MySQLRow+SQL.swift +++ b/Sources/MySQLKit/MySQLRow+SQL.swift @@ -11,7 +11,7 @@ extension MySQLRow { } } -extension MySQLNIO.MySQLRow: @unchecked Sendable {} // Fully qualifying the type name implies @retroactive +extension MySQLNIO.MySQLRow: @unchecked Swift.Sendable {} // Fully qualifying the type names implies @retroactive /// An error used to signal that a column requested from a `MySQLRow` using the `SQLRow` interface is not present. struct MissingColumn: Error { diff --git a/Sources/MySQLKit/Optional+MySQLDataConvertible.swift b/Sources/MySQLKit/Optional+MySQLDataConvertible.swift index 46e90e4..71935a2 100644 --- a/Sources/MySQLKit/Optional+MySQLDataConvertible.swift +++ b/Sources/MySQLKit/Optional+MySQLDataConvertible.swift @@ -1,7 +1,7 @@ import MySQLNIO /// Conforms `Optional` to `MySQLDataConvertible` for efficiency. -extension Optional: MySQLDataConvertible where Wrapped: MySQLDataConvertible { +extension Swift.Optional: MySQLNIO.MySQLDataConvertible where Wrapped: MySQLNIO.MySQLDataConvertible { // See `MySQLDataConvertible.init?(mysqlData:)`. public init?(mysqlData: MySQLData) { if mysqlData.buffer != nil {