我有JSON
输入MySQL
数据库。
这是有效的 JSON。
["Text 1","Text 2"]
在MySQL
我可以执行:
UPDATE table_name SET col='["Text 1","Text 2"]' WHERE id=1;
但在Prisma 2.0
db.table_name.create({
data: {
col: ["Text 1", "Text 2"]
}
})
我有这样的错误:
Failed to validate the query `Error occurred during query validation & transformation:
Mutation (object)
↳ updateOneFile (field)
↳ data (argument)
↳ FileUpdateInput (object)
↳ text (field)
↳ Value types mismatch. Have: List([String("Text 1"), String("Text 2")]), want: Scalar(Json)` at `.Mutation.updateOneFile.data.FileUpdateInput.text`
at PrismaClientFetcher.request (/home/daniel/pro/ocr/backend/node_modules/@prisma/client/runtime/index.js:1:85701)
at processTicksAndRejections (internal/process/task_queues.js:94:5) {
code: 'P2009',
meta: {
query_validation_error: 'Error occurred during query validation & transformation:\n' +
'Mutation (object)\n' +
' ↳ updateOneFile (field)\n' +
' ↳ data (argument)\n' +
' ↳ FileUpdateInput (object)\n' +
' ↳ text (field)\n' +
' ↳ Value types mismatch. Have: List([String("Text 1"), String("Text 2")]), want: Scalar(Json)',
query_position: '.Mutation.updateOneFile.data.FileUpdateInput.text'
}
}
在这个例子中:
My table name: "File"
My column name: "text"