-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix(orm): enum doesn't properly use default postgres schema #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe Prisma schema generator is updated to optimize enum attribute iteration by computing attributes once before filtering. Additionally, when a datasource declares schemas without an explicit @@Schema attribute on an enum, a default @@Schema attribute is automatically added using the Postgres default schema name. Comprehensive test coverage validates enum behavior across custom schema scenarios. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (6)
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 |
|
Claude finished @ymc9's task —— View job Code Review: Fix enum schema handling for PostgreSQL
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug where enum types weren't properly receiving the default PostgreSQL schema when the datasource declares a schemas setting. The fix ensures that enums without an explicit @@schema attribute automatically receive the default schema (either from defaultSchema or 'public'), matching the existing behavior for models.
Key changes:
- Added logic to automatically apply
@@schemaattribute to enums whenschemasis defined in the datasource - Enhanced tests to include enum types with role fields, ensuring enum schema behavior is properly validated
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/sdk/src/prisma/prisma-schema-generator.ts | Added logic in generateEnum to automatically add @@schema attribute with default schema name when datasource has schemas setting and enum lacks explicit @@schema, mirroring existing model behavior |
| tests/e2e/orm/client-api/pg-custom-schema.test.ts | Added enum types (Role, FooRole, BarRole) and corresponding role fields to models across multiple test cases to validate that enums properly receive schema assignments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Summary by CodeRabbit
Release Notes