[英]Prisma nested create throws unknown arg error while prisma example works
[英]prisma create with nested connect throws error
我遇到了一個問題,在create
調用中將模型連接到另一個模型中的多個項目似乎會引發以下錯誤:
Invalid `prisma.movie.create()` invocation:
Error occurred during query execution:
ConnectorError(ConnectorError {
user_facing_error: None, kind: QueryError(Error {
kind: Db, cause: Some(DbError {
severity: "ERROR", parsed_severity: None, code: SqlState("42601"),
message: "syntax error at or near \"ON\"", detail: None, hint: None,
position: Some(Original(93)), where_: None, schema: None, table: None,
column: None, datatype: None, constraint: None,
file: Some("scan.l"), line: Some(1006), routine: Some("scanner_yyerror")
})
})
})
const genresData = genres.map((genre) => ({ name: genre.name }));
await prisma.movie.create({
data: {
title: details.title,
description: details.overview,
// ...
genres: {
connect: genresData,
},
},
select: {
tmdbId: true,
title:true,
// ...
},
});
假設Genre
模型有一個唯一的字段name
。
奇怪的是,在我的本地機器上似乎一切正常,但在托管我的應用程序的服務器上卻沒有。
我似乎已經解決了這個問題。
就我而言,我在本地計算機和服務器上運行的 PostgreSQL 版本之間存在差異。
當我在本地使用 postgresql-13 時,我的服務器正在運行 postgresql-9.2,因此升級我服務器的 Postgres 版本解決了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.