drizzle-team / drizzle-team/drizzle-orm
[BUG]: JSONB type can not serialize when json contains bigint
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
1.0.0-rc.2-e38a2ba
### What version of `drizzle-kit` are you using?
1.0.0-rc.2-e38a2ba
### Other packages
@electric-sql/pglite@0.4.5 @electric-sql/pglite-tools@0.3.5
### Describe the Bug
node25.9.0 bun1.3.13
```ts
interface Extra {
xid: bigint
}
const d = t.pgTable("d", {
id: t.serial().primaryKey(),
extra: t.jsonb().$type(),
});
db.insert(d).values({extra: {xid: 0n}})
```
if schema has jsonb and values set this jsonb with object with bigint, it will cause errors:
```
Caused by: TypeError: Do not know how to serialize a BigInt
❯ serialize node_modules/@electric-sql/pglite/dist/chunk-ACJ7KGEC.js:1:2060
❯ node_modules/@electric-sql/pglite/dist/chunk-HDIMFN25.js:8:2487
❯ node_modules/@electric-sql/pglite/dist/chunk-HDIMFN25.js:8:2385
```
maybe the pglite adapters need pre-handle the bigint in json input
see https://pglite.dev/docs/api#query-options
Add a option to set json and jsonb with custom parsers and serializers, so we can use json-bigint to replace built-in JSON method.
Contributor guide
Assessment
This issue has not been assessed yet.