fix(zod): generate optional field as z.optional() rather than z.nullish() to be consistent with Prisma's typing#1426
Conversation
…llish()` to be consistent with Prisma's typing
WalkthroughWalkthroughThe update enhances the schema generation logic in the Zod utility by replacing Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/schema/src/plugins/zod/utils/schema-gen.ts (1 hunks)
Additional comments not posted (2)
packages/schema/src/plugins/zod/utils/schema-gen.ts (2)
147-147: Ensure that the addition of.optional()here correctly handles fields withauth()in@default(). This change aligns with the PR's objective to treat such fields as optional rather than having a default value.
155-155: The addition of.optional()here is crucial for handling fields explicitly marked as optional in the data model. This change is consistent with the PR's goal to align Zod schema generation with Prisma's typing for optional fields.
There was a problem hiding this comment.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/schema/src/plugins/zod/utils/schema-gen.ts (1 hunks)
- packages/schema/src/utils/pkg-utils.ts (5 hunks)
- tests/regression/tests/issue-1378.test.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- packages/schema/src/utils/pkg-utils.ts
Files skipped from review as they are similar to previous changes (1)
- packages/schema/src/plugins/zod/utils/schema-gen.ts
Additional comments not posted (1)
tests/regression/tests/issue-1378.test.ts (1)
3-46: Ensure the test case accurately reflects the changes made in the PR.
Fixes #1378