diff --git a/Sources/PerfectSQLite/SQLiteCRUD.swift b/Sources/PerfectSQLite/SQLiteCRUD.swift index 38d78be..ad83c60 100644 --- a/Sources/PerfectSQLite/SQLiteCRUD.swift +++ b/Sources/PerfectSQLite/SQLiteCRUD.swift @@ -110,6 +110,11 @@ class SQLiteCRUDRowReader: KeyedDecodingContainerProtocol { throw CRUDDecoderError("Invalid Date string \(str).") } return date as! T + case .codable: + guard let data = statement.columnText(position: columnPosition(key)).data(using: .utf8) else { + throw CRUDDecoderError("Unsupported type: \(type) for key: \(key.stringValue)") + } + return try JSONDecoder().decode(type, from: data) } } func nestedContainer(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer where NestedKey : CodingKey { @@ -278,6 +283,8 @@ class SQLiteGenDelegate: SQLGenDelegate { typeName = "TEXT" case .date: typeName = "TEXT" + case .codable: + typeName = "TEXT" } } let addendum: String