Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 431
A. L Avatar asked Mar 05 '23 13:03

A. L


1 Answers

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[])
like image 160
Andomar Avatar answered Mar 27 '23 03:03

Andomar