Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to insert values of type bigint[] #837

Open
darkgnotic opened this issue Mar 26, 2024 · 0 comments
Open

Unable to insert values of type bigint[] #837

darkgnotic opened this issue Mar 26, 2024 · 0 comments

Comments

@darkgnotic
Copy link

darkgnotic commented Mar 26, 2024

Using postgres({types: {bigint: postgres.BigInt}}) I am able to read both int8 and int8[] values as bigints.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant