-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix(delegate): nested create/connect in delegate model requires reference fields #1901
Conversation
…ence fields fixes #1894
📝 WalkthroughWalkthroughThe pull request introduces enhancements to the Changes
Assessment against linked issues
Possibly related PRs
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
tests/regression/tests/issue-1894.test.ts (1)
50-50
: Consider omitting explicit 'id' assignment for auto-incremented fieldIn
await db.a.create({ data: { id: 0 } });
, you're explicitly setting theid
for a field defined with@id @default(autoincrement())
. This may lead to conflicts or unexpected behavior. It's advisable to omit theid
field and allow the database to auto-generate it.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
packages/schema/src/plugins/prisma/schema-generator.ts
(1 hunks)tests/regression/tests/issue-1894.test.ts
(1 hunks)
🔇 Additional comments (3)
packages/schema/src/plugins/prisma/schema-generator.ts (1)
643-685
: Logic for relation attribute generation is sound
The updated logic for generating relation attributes appropriately handles foreign key fields and self-relations. The introduction of relKeyPairs
and conditionally including 'fields' and 'references' in the @relation
attribute enhances the accuracy of the generated Prisma schema.
tests/regression/tests/issue-1894.test.ts (2)
3-53
: Regression test effectively validates the fix for issue #1894
The added test suite correctly sets up the models and verifies that nested create/connect operations in delegate models function as expected. This ensures that the regression identified in issue #1894 is resolved.
51-51
: Verify the use of 'toResolveTruthy' in the test assertion
Ensure that toResolveTruthy
is a valid matcher in your testing framework. If not, consider using a standard matcher like .resolves.toBeTruthy()
to assert that the promise resolves successfully.
fixes #1894