gpt4 book ai didi

javascript - pg-promise - 错误运算符不存在 : bigint = bigint[]

转载 作者:行者123 更新时间:2023-11-29 12:50:42 29 4
gpt4 key购买 nike

我正在尝试运行查询:

let query =
`
DELETE FROM
${table_name}
WHERE
_id IN ($1::bigint[])
AND
account_id = $2
`
let fields =
[
_ids,
account_id,
]

但它给了我错误:

operator does not exist: bigint = bigint[]

_ids 是一个数组。

注意

实现答案后我遇到的错误是:

GraphQLError: Int cannot represent non-integer value: []

这只是一个 GraphQL 错误,与 postgres 无关。

最佳答案

IN 运算符需要一个 set of rows with exactly one column , 或 parenthesized list of scalar expressions .它不接受数组。

One answer建议 :list,它告诉 pg-promise 做正确的事:

WHERE _id IN ($1:list)

Another answer建议 = any,其中 ANYPostgres operator确实接受数组:

WHERE _id = ANY ($1::int[])

关于javascript - pg-promise - 错误运算符不存在 : bigint = bigint[],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54611168/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com