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

时间:2019-02-09 21:55:56

标签: javascript node.js postgresql pg-promise

我正在尝试运行查询:

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无关。

1 个答案:

答案 0 :(得分:2)

IN运算符期望set of rows with exactly one columnparenthesized list of scalar expressions。它不接受数组。

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

WHERE _id IN ($1:list)

Another answer建议使用= any,其中ANY是一个接受数组的Postgres operator

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