File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -495,19 +495,22 @@ private class SQLiteDecoder: Decoder {
495495 try ? row. get ( Expression ( key. stringValue) )
496496 }
497497
498- func decode < T> ( _ type: T . Type , forKey key: Key ) throws -> T ? where T: Swift . Decodable {
498+ func decodeIfPresent < T> ( _ type: T . Type , forKey key: Key ) throws -> T ? where T: Swift . Decodable {
499499 switch type {
500500 case is Data . Type :
501- let data = try row. get ( Expression < Data > ( key. stringValue) )
502- return data as? T
501+ if let data = try ? row. get ( Expression < Data > ( key. stringValue) ) {
502+ return data as? T
503+ }
503504 case is Date . Type :
504- let date = try row. get ( Expression < Date > ( key. stringValue) )
505- return date as? T
505+ if let date = try ? row. get ( Expression < Date > ( key. stringValue) ) {
506+ return date as? T
507+ }
506508 case is UUID . Type :
507- let uuid = try row. get ( Expression < UUID > ( key. stringValue) )
508- return uuid as? T
509+ if let uuid = try ? row. get ( Expression < UUID > ( key. stringValue) ) {
510+ return uuid as? T
511+ }
509512 default :
510- guard let JSONString = try row. get ( Expression < String ? > ( key. stringValue) ) else {
513+ guard let JSONString = try ? row. get ( Expression < String ? > ( key. stringValue) ) else {
511514 throw DecodingError . typeMismatch ( type, DecodingError . Context ( codingPath: codingPath,
512515 debugDescription: " an unsupported type was found " ) )
513516 }
You can’t perform that action at this time.
0 commit comments