@@ -26,20 +26,6 @@ extension PostgreSQLDatabase: QuerySupporting {
2626 }
2727 modelData = try dict. values. map { codableData -> PostgreSQLData in
2828 switch codableData {
29- case . bool( let value) : return try value. convertToPostgreSQLData ( )
30- case . int( let value) : return try value. convertToPostgreSQLData ( )
31- case . int8( let value) : return try value. convertToPostgreSQLData ( )
32- case . int16( let value) : return try value. convertToPostgreSQLData ( )
33- case . int32( let value) : return try value. convertToPostgreSQLData ( )
34- case . int64( let value) : return try value. convertToPostgreSQLData ( )
35- case . uint( let value) : return try value. convertToPostgreSQLData ( )
36- case . uint8( let value) : return try value. convertToPostgreSQLData ( )
37- case . uint16( let value) : return try value. convertToPostgreSQLData ( )
38- case . uint32( let value) : return try value. convertToPostgreSQLData ( )
39- case . uint64( let value) : return try value. convertToPostgreSQLData ( )
40- case . float( let value) : return try value. convertToPostgreSQLData ( )
41- case . double( let value) : return try value. convertToPostgreSQLData ( )
42- case . string( let value) : return try value. convertToPostgreSQLData ( )
4329 case . null: return PostgreSQLData ( type: . void)
4430 case . encodable( let encodable) :
4531 guard let convertible = encodable as? PostgreSQLDataCustomConvertible else {
@@ -53,8 +39,8 @@ extension PostgreSQLDatabase: QuerySupporting {
5339 )
5440 }
5541 return try convertible. convertToPostgreSQLData ( )
56- case . array, . dictionary, . decoder :
57- throw PostgreSQLError ( identifier: " codable " , reason: " Unsupported codable type: \( codableData) " )
42+ case . array, . dictionary:
43+ throw PostgreSQLError ( identifier: " codable " , reason: " Unsupported encodable type: \( codableData) " )
5844 }
5945 }
6046 default :
@@ -95,7 +81,7 @@ extension PostgreSQLDatabase: QuerySupporting {
9581
9682 // Run the query
9783 return try connection. query ( sqlString, parameters) { row in
98- let codableDict = row. mapValues { psqlData -> CodableData in
84+ let codableDict = row. mapValues { psqlData -> DecodableData in
9985 return . decoder( PostgreSQLDataDecoder ( data: psqlData) )
10086 }
10187 do {
@@ -141,8 +127,7 @@ extension PostgreSQLDatabase: QuerySupporting {
141127}
142128
143129
144- internal struct PostgreSQLDataDecoder : Decoder , SingleValueDecodingContainer {
145-
130+ internal struct PostgreSQLDataDecoder : SingleValueDecodingContainer {
146131 var codingPath : [ CodingKey ]
147132 var userInfo : [ CodingUserInfoKey : Any ]
148133 let data : PostgreSQLData
@@ -152,7 +137,6 @@ internal struct PostgreSQLDataDecoder: Decoder, SingleValueDecodingContainer {
152137 self . codingPath = [ ]
153138 }
154139
155- func singleValueContainer( ) throws -> SingleValueDecodingContainer { return self }
156140 func decodeNil( ) -> Bool { return data. data == nil }
157141 func decode( _ type: Int . Type ) throws -> Int { return try data. decode ( Int . self) }
158142 func decode( _ type: Int8 . Type ) throws -> Int8 { return try data. decode ( Int8 . self) }
@@ -180,21 +164,4 @@ internal struct PostgreSQLDataDecoder: Decoder, SingleValueDecodingContainer {
180164 }
181165 return try convertible. convertFromPostgreSQLData ( data) as! T
182166 }
183-
184- // unsupported
185- func container< Key> ( keyedBy type: Key . Type ) throws -> KeyedDecodingContainer < Key > where Key : CodingKey {
186- throw PostgreSQLError (
187- identifier: " decoding " ,
188- reason: " Keyed decoding container not supported " ,
189- suggestedFixes: [ " Use a nested struct isntead " ]
190- )
191- }
192-
193- func unkeyedContainer( ) throws -> UnkeyedDecodingContainer {
194- throw PostgreSQLError (
195- identifier: " decoding " ,
196- reason: " Unkeyed decoding container not supported " ,
197- suggestedFixes: [ " Use a nested struct isntead " ]
198- )
199- }
200167}
0 commit comments