porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.37k stars 267 forks source link

Boolean array type inference error #471

Open uasan opened 2 years ago

uasan commented 2 years ago

Boolean array, always passed as a boolean value, here is an example:

await sql`SELECT ${[false, true]} AS bool_array`
// Result(1) [ { bool_array: false } ]

this query is throwing an error

await sql`SELECT ${[true, false]}::bool[]`;
// Error cannot cast type boolean to boolean[]

I think this PR solves this problem https://github.com/porsager/postgres/pull/392

binikingi commented 1 year ago

For now what im doing is this:

await sql`SELECT ${[false, false].map(x => x ? 1 : 0)}::INT[]::BOOLEAN[]`