Closed mehmetkarakamis closed 3 years ago
The second parameter is already an array so you end up creating an array of an array (and then unnesting that). Remove the ARRAY[...]
and instead explicitly cast the parameter to an int[]
:
const x = 1;
const y = [2,3,4];
client.query(
"INSERT INTO privileges (id_authorizing, id_authorized) SELECT $1, UNNEST($2::int[])",
// ^^^^^^^
[x,y]
);
It seems that a statement work good on PostreSQL but fails on node-postgres.
Re-produce the error:
Step-1: Create two tables:
Step 2: Create two values to write on database.
Throws an error like:
error: column "id_authorized" is of type integer but expression is of type text
This statement seems to work on PostgreSQL:
Output: