drizzle-orm
drizzle-orm copied to clipboard
[BUG]: `Do not know how to serialize a BigInt` errors when using BigInt in `default(0n)` directive
What version of drizzle-orm are you using?
0.29.3
What version of drizzle-kit are you using?
0.20.14
Describe the Bug
- I have a
schema.tsfile where I have a value of typeBigIntwith a.default(0n)directive. - When I want to run a
drizzle-kitcommand likedrizzle-kit generate:pg, it causes anDo not know how to serialize a BigInterror.
Schema
export const myTable = pgTable('my_table', {
id: bigserial('id', { mode: 'bigint' }).primaryKey(),
value: bigint('value', {
mode: 'bigint',
})
.notNull()
.default(0n), // <- causes the error
});
Error
Reading config file '.../drizzle.config.ts'
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at applyJsonDiff (.../node_modules/drizzle-kit/bin.cjs:5429:27)
at applySnapshotsDiff (.../node_modules/drizzle-kit/bin.cjs:17397:20)
at prepareSQL (.../node_modules/drizzle-kit/bin.cjs:15055:20)
at prepareAndMigratePg (.../node_modules/drizzle-kit/bin.cjs:14834:48)
at async Command.<anonymous> (.../node_modules/drizzle-kit/bin.cjs:63024:3)
Expected behavior
Know how to seriazile BigInt values in .default(...) directive.
Environment & setup
No response
As a workaround:
export const myTable = pgTable('my_table', {
id: bigserial('id', { mode: 'bigint' }).primaryKey(),
value: bigint('value', {
mode: 'bigint',
})
.notNull()
.default(sql`0::bigint`), // <- causes the error
});