1

我有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"

https://github.com/prisma/prisma/issues/2682

4

1 回答 1

1

我发现这是固定的

https://www.npmjs.com/package/@prisma/cli/v/2.0.0-alpha.1286

5天前

https://github.com/prisma/prisma/issues/2619

那里报告了非常相似的问题

https://github.com/prisma/prisma/issues/2619

当前状态:Waiting for documentation

https://github.com/prisma/prisma/issues/2322

进步:

https://github.com/prisma/prisma/milestone/35

于 2020-06-07T18:33:54.913 回答