Describe the bug
When arrays are passed as parameters to the query function, the "dumb" version of the JSON.stringify is used, and this fails for BigInts.
To Reproduce - include code sample(s)
const pg = await PGlite.create();
const myint = [{ id: 1 }, { id: 2 }];
const mybigint = [{ id: 1n }, { id: 2n }];
await pg.exec(`CREATE TABLE IF NOT EXISTS "myint" ("id" int NOT NULL);`);
await pg.exec(`CREATE TABLE IF NOT EXISTS "mybigint" ("id" bigint NOT NULL);`);
await pg.query(`INSERT INTO myint (id) SELECT x.* from json_to_recordset($1) as x(id int); `, [myint]);
console.log("got", await pg.query("SELECT * FROM myint"));
// the following line fails
await pg.query(`INSERT INTO mybigint (id) SELECT x.* from json_to_recordset($1) as x(id bigint); `, [mybigint]);
console.log("got", await pg.query("SELECT * FROM mybigint"));
Logs
got {
rows: [ { id: 1 }, { id: 2 } ],
fields: [ { name: "id", dataTypeID: 23 } ],
affectedRows: 0
}
error: Uncaught (in promise) TypeError: Do not know how to serialize a BigInt
return Array.isArray(r)
^
at stringify (<anonymous>)
at serialize (file:///home/anton/.cache/deno/npm/registry.npmjs.org/@electric-sql/pglite/0.3.15/dist/chunk-3WWIVTCY.js:249:1)
at file:///home/anton/.cache/deno/npm/registry.npmjs.org/@electric-sql/pglite/0.3.15/dist/chunk-F2DQ4FIK.js:530:3
at Array.map (<anonymous>)
at file:///home/anton/.cache/deno/npm/registry.npmjs.org/@electric-sql/pglite/0.3.15/dist/chunk-F2DQ4FIK.js:530:3
Details
Additional context
This also affects the json initial insert mode for pglite-sync
Describe the bug
When arrays are passed as parameters to the
queryfunction, the "dumb" version of theJSON.stringifyis used, and this fails forBigInts.To Reproduce - include code sample(s)
Logs
Details
Additional context
This also affects the
jsoninitial insert mode forpglite-sync