fix(cli): db pull missing relation name if one model has both to-one and to-many relation for another model#2761
Conversation
…and to-many relation for another model
📝 WalkthroughWalkthroughChangesThe relation synchronization predicate now normalizes schema comparisons and no longer requires the first referenced column to match. Database pull behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
@copilot The CI failed because of the new added test case 'should preserve opposite-direction relations between the same two tables' failed for mysql. Please help fix it |
Fixed in commit The root cause: MySQL's introspection returns The fix adds a |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@packages/cli/src/actions/db.ts`:
- Around line 178-190: Update the similarRelations filter in the
resolvedRelations counting logic to compare relation-column identity in addition
to schema and table matches. Preserve the existing direction-aware branches,
requiring each branch to match the corresponding local and referenced column
arrays while keeping reversed relations mapped to the opposite arrays.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4d6eba26-592e-4356-bbd8-56856371d207
📒 Files selected for processing (1)
packages/cli/src/actions/db.ts
Summary by CodeRabbit
Bug Fixes
Tests
db pulltest coverage across PostgreSQL, MySQL, and SQLite.