Skip to content

Commit f9d4410

Browse files
authored
fix: error when logging prisma queries whose data contains BigInt (#2121)
1 parent 4900d08 commit f9d4410

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/runtime/src/enhancements/node/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { DbClientContract } from '../../types';
77
*/
88
// eslint-disable-next-line @typescript-eslint/no-explicit-any
99
export function formatObject(value: any, multiLine = true) {
10-
return multiLine ? safeJsonStringify(value, undefined, 2) : safeJsonStringify(value);
10+
return safeJsonStringify(value, (_, v) => (typeof v === 'bigint' ? v.toString() : v), multiLine ? 2 : undefined);
1111
}
1212

1313
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { loadSchema } from '@zenstackhq/testtools';
2+
3+
describe('issue 2106', () => {
4+
it('regression', async () => {
5+
const { enhance } = await loadSchema(
6+
`
7+
model User {
8+
id Int @id
9+
age BigInt
10+
@@allow('all', true)
11+
}
12+
`,
13+
{ logPrismaQuery: true }
14+
);
15+
16+
const db = enhance();
17+
await expect(db.user.create({ data: { id: 1, age: 1n } })).toResolveTruthy();
18+
});
19+
});

0 commit comments

Comments
 (0)