fix: auto-add "views" preview feature to generated Prisma schema (#2376)#2402
fix: auto-add "views" preview feature to generated Prisma schema (#2376)#2402
Conversation
When a ZModel schema contains `view` declarations without an explicit generator block, the generated Prisma schema now automatically includes `previewFeatures = ["views"]` in the default generator, preventing the P1012 validation error during `db push` and `migrate`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @ymc9's task —— View job PR Review Complete ✅Reviewing PR #2376: Auto-add "views" preview feature to generated Prisma schema Review Checklist:
✅ Code Quality & Best PracticesExcellent implementation overall! The code follows established patterns in the codebase:
✅ Performance ConsiderationsNo performance concerns identified:
✅ Security AssessmentNo security implications:
|
📝 WalkthroughWalkthroughThe Prisma schema generator's preview features computation logic is refactored to dynamically collect features based on data source extensions and model views, replacing the previous static approach. A regression test validates the "views" preview feature is correctly added when schema views exist. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/regression/test/issue-2376.test.ts (1)
38-40: Tighten the assertion to target the previewFeatures array.
toContain('views')could pass if “views” appears elsewhere; a regex scoped to the previewFeatures assignment avoids false positives.Suggested tweak
- expect(prismaSchema).toContain('previewFeatures'); - expect(prismaSchema).toContain('views'); + expect(prismaSchema).toContain('previewFeatures'); + expect(prismaSchema).toMatch(/previewFeatures\s*=\s*\[[^\]]*"views"/);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/regression/test/issue-2376.test.ts` around lines 38 - 40, The assertions on prismaSchema are too loose—keep the check scoped to the previewFeatures array so 'views' elsewhere won't produce false positives: update the two expect calls around prismaSchema to use a single regex (or toMatch) that targets the previewFeatures assignment and asserts that the array contains 'views' (match "previewFeatures" followed by an array literal that includes 'views'); reference the existing prismaSchema variable and the previewFeatures/'views' tokens when applying this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/regression/test/issue-2376.test.ts`:
- Around line 38-40: The assertions on prismaSchema are too loose—keep the check
scoped to the previewFeatures array so 'views' elsewhere won't produce false
positives: update the two expect calls around prismaSchema to use a single regex
(or toMatch) that targets the previewFeatures assignment and asserts that the
array contains 'views' (match "previewFeatures" followed by an array literal
that includes 'views'); reference the existing prismaSchema variable and the
previewFeatures/'views' tokens when applying this change.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/sdk/src/prisma/prisma-schema-generator.tstests/regression/test/issue-2376.test.ts
When a ZModel schema contains
viewdeclarations without an explicitgenerator block, the generated Prisma schema now automatically includes
previewFeatures = ["views"]in the default generator, preventing theP1012 validation error during
db pushandmigrate.Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
fixes #2376
Summary by CodeRabbit
Bug Fixes
Tests