zod-prisma-types icon indicating copy to clipboard operation
zod-prisma-types copied to clipboard

[BUG] Prisma 6.6.0 incompatibility

Open zcvaters opened this issue 8 months ago • 9 comments

Describe the bug I'm trying to use the zod generator but it's failing on 6.6.0.

Screenshots

Image

Package versions (please complete the following information):

  • zod: 3.2.4
  • prisma: 6.6.0

Additional context

zcvaters avatar Apr 18 '25 18:04 zcvaters

Prisma 6.7 is fine

zcvaters avatar Apr 29 '25 19:04 zcvaters

@zcvaters Just tested with Prisma 6.7, the issue persists

Image Image

nervestaple avatar Apr 29 '25 20:04 nervestaple

Try switching back to the prisma-client-js generator instead of the new prisma-client generator.

CarterRoll avatar Apr 30 '25 17:04 CarterRoll

Any solution that doesn't involve switching back?

nervestaple avatar Jun 10 '25 14:06 nervestaple

Anyone else having this problem -- added this script to our build process right after npx prisma generate, hopefully it won't be necessary for too much longer...

# this is only necessary because the zod schema generator has a bug that will soon be patched
sed "s/Prisma.NullTypes.DbNull | Prisma.NullTypes.JsonNull/typeof Prisma.NullTypes.DbNull | typeof Prisma.NullTypes.JsonNull/" prisma/generated/zod/index.ts > __tmpzod.ts && mv __tmpzod.ts prisma/generated/zod/index.ts
echo "Patched generated zod schema -- check if it's been fixed! https://github.com/chrishoermann/zod-prisma-types/issues/335"

nervestaple avatar Jun 10 '25 14:06 nervestaple

Me too. I need to use the prisma-client in order to have the native typescript client

leegunwoo98 avatar Jun 21 '25 02:06 leegunwoo98

If you’re blocked by Prisma 6.x / the new prisma-client generator here, consider Prisma Zod Generator (actively maintained). It supports the new client generator and Zod 4, so you don’t need to switch back to prisma-client-js.

Highlights:

  • Prisma 6 + new prisma-client generator support
  • Zod 4 compatibility
  • Models-only and single-file output modes for minimal footprints
  • Dual exports (typed ZodObject + pure Zod), schema variants
  • Unified configuration system with auto-discovery and recipes (unique here)
  • Active releases (latest: v1.4.2)

Repo/Docs: https://github.com/omar-dulaimi/prisma-zod-generator Changelog: https://github.com/omar-dulaimi/prisma-zod-generator/blob/master/CHANGELOG.md Issues/Feature requests/PRs welcome: https://github.com/omar-dulaimi/prisma-zod-generator/issues

omar-dulaimi avatar Aug 10 '25 04:08 omar-dulaimi

@omar-dulaimi can you explain how to make it work with the new generator? by default it imports everything from @prisma/client, which isn't meant to be used with the new generator (in favor of importing client types directly from ./prisma/generated)

nervestaple avatar Aug 11 '25 16:08 nervestaple

@omar-dulaimi can you explain how to make it work with the new generator? by default it imports everything from @prisma/client, which isn't meant to be used with the new generator (in favor of importing client types directly from ./prisma/generated)

You just need to update to latest version, and use the new client in your prisma schema. Don't forget to set output path, it's become required.

Generator will handle the rest itself in terms of using the right paths.

omar-dulaimi avatar Aug 13 '25 09:08 omar-dulaimi