Hi — I'm hitting a bug where kysely-postgres-js fails to compile queries when the value passed to .where('col', 'in', value) is a TypedArray (Int32Array) instead of a plain JS Array.
What happens
Bun SQL returns PostgreSQL integer[] columns as Int32Array (typed array), not number[].
Kysely call like:
const somedata = await db.selectFrom('sometable').selectAll().executeTakeFirst();
const dataIds = somedata?.dataIds; // Int32Array from Bun SQL
await db.selectFrom('wadus').where('id', 'in', dataIds).selectAll().execute();
The PostgresQueryCompiler expects a plain JavaScript array to expand the IN clause (IN ($1, $2, ...)). When given an Int32Array the compiler produces malformed SQL / crashes (it doesn't iterate/serialize the typed array correctly).
Expected behavior
Kysely should accept any array-like or iterable of primitives for the 'in' operator, including TypedArrays (Int8Array, Uint8Array, Int32Array, etc.), and expand them correctly into positional parameters.
At minimum, detect TypedArray and convert with Array.from(value) before compilation.
Environment
bun 1.3.8 (Bun SQL returns Int32Array for integer[] columns)
Kysely + kysely-postgres-js (version unconfirmed)
Actual workaround
Manually convert typed arrays before passing to Kysely:
await db.selectFrom('wadus').where('id', 'in', Array.from(dataIds)).selectAll().execute();
Happy to provide a small repro if helpful. Thank you.
Hi — I'm hitting a bug where kysely-postgres-js fails to compile queries when the value passed to .where('col', 'in', value) is a TypedArray (Int32Array) instead of a plain JS Array.
What happens
Bun SQL returns PostgreSQL integer[] columns as Int32Array (typed array), not number[].
Kysely call like:
The PostgresQueryCompiler expects a plain JavaScript array to expand the IN clause (IN ($1, $2, ...)). When given an Int32Array the compiler produces malformed SQL / crashes (it doesn't iterate/serialize the typed array correctly).
Expected behavior
Kysely should accept any array-like or iterable of primitives for the 'in' operator, including TypedArrays (Int8Array, Uint8Array, Int32Array, etc.), and expand them correctly into positional parameters.
At minimum, detect TypedArray and convert with Array.from(value) before compilation.
Environment
bun 1.3.8 (Bun SQL returns Int32Array for integer[] columns)
Kysely + kysely-postgres-js (version unconfirmed)
Actual workaround
Manually convert typed arrays before passing to Kysely:
Happy to provide a small repro if helpful. Thank you.