-
-
Notifications
You must be signed in to change notification settings - Fork 17
fix(orm): fix query errors with many-to-many relations between delegate models #506
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
WalkthroughThis pull request fixes a query execution error when handling many-to-many relations between delegate (inherited) models. The fix modifies the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (7)📓 Common learnings📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-10-21T16:09:31.218ZApplied to files:
🧬 Code graph analysis (1)tests/regression/test/issue-505.test.ts (1)
⏰ 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). (2)
🔇 Additional comments (4)
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 PR Review: Fix for Many-to-Many Relations Between Delegate ModelsI've reviewed this pull request that addresses query errors with many-to-many relations between delegate models. Here's my comprehensive feedback: Review Tasks:
Code Quality & Best Practices ✅Positive aspects:
Suggestions:
Bug Analysis ✅Root cause properly addressed:
Fix validation:
Performance Considerations ✅Minimal performance impact:
Security Concerns ✅No security issues identified:
Test Coverage ✅Comprehensive test scenario:
Test quality:
Overall Assessment 🎯This is a high-quality fix that:
Recommendations
Summary: This PR successfully fixes a specific edge case with many-to-many relations in delegate model hierarchies. The implementation is clean, safe, and well-validated through testing. |
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 query errors that occur when using many-to-many relations between delegate models. The issue arose because when a concrete model (e.g., TelegramMessage) inherits a many-to-many relation field from its delegate base model (e.g., Message), the system was using the concrete model name instead of the base model name when computing join table names and foreign key references, causing query failures.
Key Changes:
- Modified
getManyToManyRelationfunction to useoriginModelfield for inherited relation fields - Added comprehensive regression test verifying both directions of many-to-many relations between delegate models
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/orm/src/client/query-utils.ts | Updated getManyToManyRelation to resolve base model name using originModel field for inherited relation fields, ensuring correct join table name and FK ordering |
| tests/regression/test/issue-505.test.ts | Added regression test with many-to-many relations between delegate models (Media/TelegramPhoto and Message/TelegramMessage), verifying create, connect, and include operations in both directions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fixes #505
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.