Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/orm/src/client/crud/validator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ export function addBigIntValidation(schema: z.ZodBigInt, attributes: AttributeAp
if (val === undefined) {
continue;
}
const bigIntVal = BigInt(val);

match(attr.name)
.with('@gt', () => {
result = result.gt(bigIntVal);
result = result.gt(BigInt(val));
})
.with('@gte', () => {
result = result.gte(bigIntVal);
result = result.gte(BigInt(val));
})
.with('@lt', () => {
result = result.lt(bigIntVal);
result = result.lt(BigInt(val));
})
.with('@lte', () => {
result = result.lte(bigIntVal);
result = result.lte(BigInt(val));
});
}
return result;
Expand Down
16 changes: 16 additions & 0 deletions tests/regression/test/issue-423.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createTestClient } from '@zenstackhq/testtools';
import { describe, expect, it } from 'vitest';

describe('Regression for issue #423', () => {
it('verifies non-validation attributes for BigInt does not fail', async () => {
const db = await createTestClient(
`
model SampleBigInt {
id BigInt @id @map("sample_id")
data String
}`,
);
await expect(db.SampleBigInt.create({ data: { data: "create", id: BigInt(1) } })).resolves.toMatchObject({ id: BigInt(1), data: "create" });
await expect(db.SampleBigInt.update({ data: { data: "update" }, where: { id: BigInt(1) } })).resolves.toMatchObject({ id: BigInt(1), data: "update" });
});
});
Loading