Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate integer types on zod schema for Postgres integer columns #2332

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

theo-m
Copy link

@theo-m theo-m commented May 16, 2024

Appears related to #2220

…ss db vendors: tsc doesn't pass for the new comparisons
drizzle-zod/src/index.ts Outdated Show resolved Hide resolved
Comment on lines +59 to +63
test('users insert invalid number type', (t) => {
const schema = createInsertSchema(users);

t.is(schema.safeParse({ ...testUser, numberOfDogs: 7.31 }).success, false);
});
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the reason for the PR, today this test fails: parsing succeeds when it shouldn't, because postgres will fail if you try to insert a float on an integer column

@theo-m theo-m marked this pull request as ready for review May 16, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant