-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Types mismatch between the generated zod types and the prisma client types #98
Comments
@atanaskanchev thank's for the report. I'm aware of this issue and currently working on a fix for that. This has to do with an updated |
@atanaskanchev this seems to be a bit of a complex issue. I've started a discussion on the zod page on how this could be resolved. |
I rolled back Zod to 3.21.1 from 3.21.2 and that's getting me past this issue. |
Opened an issue in the zod repo: colinhacks/zod#2184 |
I tried rolling back but ran into this error:
|
I was able to get around this as well by rolling back to 3.21.1 from 3.21.4 |
Since there is no movement on the zod issue I thought of a rude override to enable the use of zod version greater than The simple solution for now would be to just add a type assertion like: export const UserCreateInputSchema: z.ZodType<Prisma.UserCreateInput> = z.object({ since the schemas work, as confirmd by using zod Any thougths on this? should probably be swichable via generator option and off by default. |
This PR fixes the problem where the generated client may contain type errors for models containing relations. This is a known problem with Zod and Prisma and is described here: chrishoermann/zod-prisma-types#98. That issue also proposes a solution with a dirty type cast: chrishoermann/zod-prisma-types#98 (comment) which is implemented in this PR. This PR removes the need for pinning the version of Zod (#700).
Rolling back zod to 3.21.1 leads to my project not working any more. The reason is that this project uses uuid v7 and it seems that zod does not recognize uuid v7 as valid until later versions (3.22.4 works). For more info see electric-sql/electric#1153 (comment) |
zod 3.23 has been released, and may include a fix for the XOR issue: colinhacks/zod#2184 (reference) |
zod-prisma-types generates a schema for a field missing in the prisma generated types
The Prisma schema
the generated zod type having an error
the generated prisma type
the ts error
The text was updated successfully, but these errors were encountered: