fix(orm): handle self-referential relations in delegate models during schema push#2449
Conversation
|
Claude finished @ymc9's task —— View job Code Review in Progress
|
|
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 (2)
📝 WalkthroughWalkthroughFixes a cyclic dependency error in delegate models with self-referential relations by adding a guard in the topological sort logic to skip self-edges. Includes a regression test validating that delegate models can now safely reference themselves without triggering false cycle detection. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |

Summary
toposortwhen a model uses@@delegateinheritance and also has a self-referential relation (e.g. a parent/replies pattern)SchemaDbPusher.sortModelswas adding a[Post, Post]edge to the dependency graph for self-referential FKs, whichtoposortcorrectly rejects as a cyclefield.type === model.name) when building the topological sort graphTest plan
tests/regression/test/issue-2435.test.tsthat reproduces the exact schema from the issue reportCloses #2435
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests