fix: rename native type mappings to match datasource during Prisma schema generation#2760
fix: rename native type mappings to match datasource during Prisma schema generation#2760sanny-io wants to merge 5 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughPrisma schema generation now rewrites native type mappings from ChangesNative type mapping generation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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)
packages/sdk/src/prisma/prisma-schema-generator.ts (1)
343-350: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd missing semicolon.
For consistency with the rest of the file, consider adding a semicolon at the end of this statement.
♻️ Proposed refactor
if (this.isNativeTypeMappingAttribute(attr)) { const dataSource = this.zmodel.declarations.find(isDataSource); if (dataSource) { - attrName = attrName.replace('`@db`', `@${dataSource.name}`) + attrName = attrName.replace('`@db`', `@${dataSource.name}`); } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/sdk/src/prisma/prisma-schema-generator.ts` around lines 343 - 350, Add the missing semicolon to the attrName reassignment statement in makeFieldAttribute, matching the file’s existing statement style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/sdk/src/prisma/prisma-schema-generator.ts`:
- Around line 343-350: Add the missing semicolon to the attrName reassignment
statement in makeFieldAttribute, matching the file’s existing statement style.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e7af160b-8b8a-43cc-a62f-fe2352772790
📒 Files selected for processing (2)
packages/cli/test/prisma-schema-gen.test.tspackages/sdk/src/prisma/prisma-schema-generator.ts
Prisma's native type mappings rely on the datasource name. This is a problem because ZenStack uses a hardcoded prefix of
@db.*for native type mappings.For example, the following schema is valid in ZenStack, but invalid in Prisma. Migration commands will fail.
This change renames native type mappings to match the datasource during Prisma schema generation. An alternative to this is renaming the datasource itself, but since that's user-defined, I thought this was less invasive.
Summary by CodeRabbit
Summary by CodeRabbit
@ds.Text,@ds.Boolean,@ds.JsonB,@ds.Timestamptz(3),@ds.ByteA) instead of emitting@db.*.@db.*mappings are not produced and the corresponding@ds.*mappings are present.