Skip to content

Update zod to v4 and patch compatibility - #1

Open
DexterStorey wants to merge 2 commits into
masterfrom
cursor/update-zod-to-v4-and-patch-compatibility-a199
Open

Update zod to v4 and patch compatibility#1
DexterStorey wants to merge 2 commits into
masterfrom
cursor/update-zod-to-v4-and-patch-compatibility-a199

Conversation

@DexterStorey

Copy link
Copy Markdown
Collaborator

Update zod-prisma-types to be compatible with Zod v4 by adjusting generator config parsing for new .default() semantics.

Zod v4 changed the behavior of .default(), causing it to short-circuit before transformations. This required reordering the transform and default calls for boolean string flags in the generator config schema to ensure correct parsing and default application.


Slack Thread

Open in Cursor Open in Web

Co-authored-by: dexter <dexter@dexterstorey.com>
@cursor

cursor Bot commented Aug 5, 2025

Copy link
Copy Markdown

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@DexterStorey

Copy link
Copy Markdown
Collaborator Author

@cursor the zod/v4 needs to be imported with zod/v4, not just zod

@cursor

cursor Bot commented Aug 5, 2025

Copy link
Copy Markdown

I updated the import paths for the zod library across the generator's codebase and usage tests. This change specifically targets zod/v4 to ensure compatibility and prepare for future Zod versions.

  • I modified the zod import statement from import { z } from 'zod'; to import { z } from 'zod/v4'; in the following core files:
    • packages/generator/src/classes/extendedDMMFInputType.ts
    • packages/generator/src/classes/extendedDMMFSchemaField.ts
    • packages/generator/src/generatorHandler.ts
    • packages/generator/src/schemas/generatorConfigSchema.ts
    • packages/generator/src/utils/getPrismaDbProvider.ts
    • packages/generator/src/utils/getPrismaVersion.ts
    • packages/generator/src/utils/skipGenerator.ts
    • packages/generator/src/functions/writeSingleFileImportStatements.ts
  • I applied the same zod/v4 import path change across all relevant content writer functions within packages/generator/src/functions/contentWriters/, including writeArgs.ts, writeCountArgs.ts, writeModelOrType.ts, writeSelect.ts, and others, to ensure consistency in generated code.
  • I updated the zod import in packages/usage/tests/implementations/decimalSchema.ts to zod/v4 to align the test suite with the new import strategy.

Open in Cursor Open in Web

Learn more about Cursor Agents

Co-authored-by: dexter <dexter@dexterstorey.com>
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.

2 participants