Bigint in SQLite results in "TypeError: Do Not Know how to serialize a BigInt"

It's failing in this section of my schema:
const users = sqliteTable("users", {
balance: blob("balance", { mode: "bigint" }).notNull().default(BigInt(0)),
id: text("id", { mode: "text" }).unique().notNull().primaryKey(),
});
const users = sqliteTable("users", {
balance: blob("balance", { mode: "bigint" }).notNull().default(BigInt(0)),
id: text("id", { mode: "text" }).unique().notNull().primaryKey(),
});
With the following error:
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at applyJsonDiff (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:5573:27)
at applySnapshotsDiff (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:17562:20)
at prepareSQL (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:15220:20)
at prepareAndMigrateSqlite (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:15163:48)
at async Command.<anonymous> (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:66406:3)
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at applyJsonDiff (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:5573:27)
at applySnapshotsDiff (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:17562:20)
at prepareSQL (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:15220:20)
at prepareAndMigrateSqlite (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:15163:48)
at async Command.<anonymous> (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:66406:3)
When I try to run drizzle-kit generate:sqlite.
3 Replies
Ricardo Romero
Ricardo RomeroOP8mo ago
I've also tried the 0n notation and it fails with the same error. I'm using bun as a package manager and sveltekit as a framework Anyone know of a suggested workaround? I'll probably end up saving it as string and doing the conversion manually
gustavo.os
gustavo.os5mo ago
Yeah, but that convo is for PostgresSQL.... There is a PR going (https://github.com/drizzle-team/drizzle-orm/pull/2579) but idk where it sits under the code review schedule
GitHub
[SQLite] Add 64 bit bigint mode to number column by MrRahulRamkumar...
Closes #1980 Allows users to enable the SQLite driver to return JavaScript bigint instead of number. Updates existing integer modes to handle the driver returning bigint. Adds new bigint mode to t...
Want results from more Discord servers?
Add your server