prisma $queryRaw 不适用于字符串中的单引号

Bar*_*dia 5 postgresql orm pg prisma

我有一个查询

select count(id), status,  "createdAt"::date from "ProjectLog" where "projectId" = (select id from "Project" where slug = ${id}) and "createdAt" > current_date - interval '${interval} day' group by "createdAt"::date, status;
Run Code Online (Sandbox Code Playgroud)

我还尝试过用户Prisma.sql在引号内传递值,但它不断抛出错误,它期望 1 个参数,但 fount 2。

我的 prisma 没有这个问题,2.20.1 这个问题只发生在版本上3.3.0

Query: select count(id) as count, status,  "createdAt"::date from "ProjectLog" where "projectId" = (select id from "Project" where slug = $1) and "createdAt" >  current_date - interval '$2 day' and key notnull group by "createdAt"::date, status
Param: ["main","30"]
PrismaClientKnownRequestError:
Invalid `prisma.queryRaw()` invocation:


  Your raw query had an incorrect number of parameters. Expected: `1`, actual: `2`.
  code: 'P1016',
  clientVersion: '3.3.0',
  meta: { expected: 1, actual: 2 }
}
Run Code Online (Sandbox Code Playgroud)

有什么建议 ?我不确定这是否是一个错误。

小智 0

在棱镜文档中没有找到一个优雅的解决方案,我什至找不到一个,但是有一种有效的方法......你可以尝试这个${'variable'}