@@ -82,7 +82,7 @@ extension PostgreSQLDatabase: QuerySupporting {
8282 // Run the query
8383 return try connection. query ( sqlString, parameters) { row in
8484 let codableDict = row. mapValues { psqlData -> DecodableData in
85- return . decoder( PostgreSQLDataDecoder ( data : psqlData) )
85+ return . decoder( psqlData)
8686 }
8787 do {
8888 let decoded = try CodableDataDecoder ( ) . decode ( D . self, from: . dictionary( codableDict) )
@@ -125,43 +125,3 @@ extension PostgreSQLDatabase: QuerySupporting {
125125 return . done
126126 }
127127}
128-
129-
130- internal struct PostgreSQLDataDecoder : SingleValueDecodingContainer {
131- var codingPath : [ CodingKey ]
132- var userInfo : [ CodingUserInfoKey : Any ]
133- let data : PostgreSQLData
134- init ( data: PostgreSQLData ) {
135- self . data = data
136- self . userInfo = [ : ]
137- self . codingPath = [ ]
138- }
139-
140- func decodeNil( ) -> Bool { return data. data == nil }
141- func decode( _ type: Int . Type ) throws -> Int { return try data. decode ( Int . self) }
142- func decode( _ type: Int8 . Type ) throws -> Int8 { return try data. decode ( Int8 . self) }
143- func decode( _ type: Int16 . Type ) throws -> Int16 { return try data. decode ( Int16 . self) }
144- func decode( _ type: Int32 . Type ) throws -> Int32 { return try data. decode ( Int32 . self) }
145- func decode( _ type: Int64 . Type ) throws -> Int64 { return try data. decode ( Int64 . self) }
146- func decode( _ type: UInt . Type ) throws -> UInt { return try data. decode ( UInt . self) }
147- func decode( _ type: UInt8 . Type ) throws -> UInt8 { return try data. decode ( UInt8 . self) }
148- func decode( _ type: UInt16 . Type ) throws -> UInt16 { return try data. decode ( UInt16 . self) }
149- func decode( _ type: UInt32 . Type ) throws -> UInt32 { return try data. decode ( UInt32 . self) }
150- func decode( _ type: UInt64 . Type ) throws -> UInt64 { return try data. decode ( UInt64 . self) }
151- func decode( _ type: Double . Type ) throws -> Double { return try data. decode ( Double . self) }
152- func decode( _ type: Float . Type ) throws -> Float { return try data. decode ( Float . self) }
153- func decode( _ type: Bool . Type ) throws -> Bool { return try data. decode ( Bool . self) }
154- func decode( _ type: String . Type ) throws -> String { return try data. decode ( String . self) }
155- func decode< T> ( _ type: T . Type ) throws -> T where T: Decodable {
156- guard let convertible = type as? PostgreSQLDataCustomConvertible . Type else {
157- throw PostgreSQLError (
158- identifier: " convertible " ,
159- reason: " Unsupported decodable type: \( type) " ,
160- suggestedFixes: [
161- " Conform \( type) to PostgreSQLDataCustomConvertible "
162- ]
163- )
164- }
165- return try convertible. convertFromPostgreSQLData ( data) as! T
166- }
167- }
0 commit comments