Unable to insert values of type `bigint[]`
darkgnotic opened this issue · comments
Darick Tong commented
Using postgres({types: {bigint: postgres.BigInt}})
I am able to read both int8
and int8[]
values as bigint
s.
I can also input values using string[]
parameters for the latter.
However, I get a failure when attempting to use a bigint[]
as a parameter.
await sql`CREATE TABLE foo(big int8, bigs int8[])`;
await sql`INSERT INTO foo ${sql({big: 9007199254740993n})}`;
expect((await sql`SELECT * FROM foo`)[0]).toEqual({
big: 9007199254740993n,
bigs: null,
});
await sql`INSERT INTO foo ${sql({bigs: ['9007199254740993']})}`;
expect((await sql`SELECT * FROM foo`)[1]).toEqual({
big: null,
bigs: [9007199254740993n],
});
// Fails with:
// PostgresError: column "bigs" is of type bigint[] but expression is of type bigint
await sql`INSERT INTO foo ${sql({bigs: [9007199254740994n]})}`;
expect((await sql`SELECT * FROM foo`)[2]).toEqual({
big: null,
bigs: [9007199254740994n],
});
Is there something more that I have to configure to be able to input bigint[]
parameters?
Thank you for your help!