pg-promise - Error operator does not exist: bigint = bigint[]
Asked Answered
W

1

6

I am trying to run the query:

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

but it's giving me the error:

operator does not exist: bigint = bigint[]

_ids is an array.

NOTE

The error I was getting once implementing the answer was:

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

This was simply a GraphQL error, nothing to do with postgres.

Worrisome answered 9/2, 2019 at 21:55 Comment(0)
M
12

The IN operator expects either a set of rows with exactly one column, or a parenthesized list of scalar expressions. It doesn't accept an array.

One answer suggests :list, which tells pg-promise to do the right thing:

WHERE _id IN ($1:list)

Another answer suggests = any, where ANY is a Postgres operator that does accept arrays:

WHERE _id = ANY ($1::int[])
Michelinamicheline answered 9/2, 2019 at 22:53 Comment(2)
for either example, I'm getting the error: GraphQLError: Int cannot represent non-integer value: [] and shouldn't it be bigint? Since the _id is bigserialWorrisome
this was actually the answer. The issue I was getting was GraphQL's error zzz.Worrisome

© 2022 - 2024 — McMap. All rights reserved.