我无法将大型(~20k)JSON blob保存到SQLite数据库中。我使用builder.bytes("data")
创建了行,该行在数据库文件中变为blob
行。当我尝试保存Byte aka Bytes数组时,我收到此错误:
S Q Lite Driver Error: Unsupported Command: Array values not supported.] [Identifier: Fluent.SQLiteDriverError.unsupported] [Possible Causes: using operations not supported by sqlite] [Suggested Fixes: verify data is not corrupt if data type should be supported by sqlite]
错误消息来自已实现的switch语句here。
在bytes
枚举中定义了一个单独的StructuredData
个案,似乎得到了SQLDriver的支持,但我不知道如何到达那里。
这是我的课程的定义方式:
final class Blob:Model { 让storage = Storage()
let uuid: String
let revision: Int
let userId: Identifier
let data: Bytes
init(uuid inUuid: String, revision inRevision: Int, data inData: [UInt8], user: User) throws {
uuid = inUuid
userId = try user.assertExists()
revision = inRevision
data = inData
}
init(row: Row) throws {
uuid = try row.get("uuid")
userId = try row.get(User.foreignIdKey)
revision = try row.get("revision")
data = try row.get("data")
}
func makeRow() throws -> Row {
var row = Row()
try row.set("uuid", uuid)
try row.set(User.foreignIdKey, userId)
try row.set("revision", revision)
try row.set("data", data)
return row
}
}
这是使用Vapor Toolbox 2.0.3和Vapor Framework 2.1.3。
答案 0 :(得分:2)
在当前版本的Vapor 2中,在将字节数组从/向节点和其他StructuredDataWrappers转换时,您不能依赖模糊>>> from itertools import combinations
>>> list(combinations(original_list, 5))[::-1]
[(4, 5, 8, 9, 11),
(2, 5, 8, 9, 11),
(2, 4, 8, 9, 11),
(2, 4, 5, 9, 11),
(2, 4, 5, 8, 11),
(2, 4, 5, 8, 9)]
/ get
方法。
相反,您必须明确指出两个方向:
set
Here是GitHub上的相关问题。