Conversation
…DeleGate sub-models (#2595) `loadBeforeUpdateEntities` built a plain `SELECT <fields> FROM <SubModel>` query, but fields referenced via `before()` in post-update policies may live on the base table of a @@DeleGate hierarchy. Postgres rejects such queries with "column does not exist". Fix: qualify every selection with its owning table (`originModel ?? model`) and LEFT JOIN any base tables that contribute inherited fields, mirroring the same `originModel` pattern used in #2591 for cursor pagination. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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)
📝 WalkthroughWalkthroughFixed Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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 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 |
|
Claude finished @ymc9's task —— View job Code Review Complete ✅I've thoroughly reviewed the changes for issue #2595. This is a well-implemented fix that addresses a specific edge case with delegate models and before-update policies. Review Checklist:
SummaryThe fix addresses a critical issue where Code Quality & Implementation ✅Strengths:
Implementation Details (lines 590-618):
Bug Analysis ✅Issue Resolution:
Performance Considerations ✅Positive aspects:
Potential concerns:
Security Assessment ✅No security concerns identified:
Test Coverage ✅Excellent test coverage: Test 1 (
Test 2 (
Test schema quality:
Minor Recommendations
Verdict: LGTM 🚀This is a high-quality fix that:
The implementation demonstrates deep understanding of both the delegate model system and the policy evaluation pipeline. Ready for merge! |
Summary
Fixes #2595.
loadBeforeUpdateEntitiesbuilt a plainSELECT <fields> FROM <SubModel>query to snapshot entity state before an update (forpost-update/before()policy evaluation). When the model is a@@delegatesub-model, fields referenced viabefore()may live on the base table — Postgres rejects with "column does not exist".originModel ?? model) using aReferenceNodeinstead of a bareColumnNodeoriginModelfix applied to cursor pagination in fix(orm): resolve delegate-inherited fields in cursor pagination #2591Test plan
tests/regression/test/issue-2595.test.tscovers the failing path: update on a@@delegatesub-model with a@@deny('post-update', before().<base-field> …)policy no longer errorsbefore().status == 'Finalized'pnpm --filter @zenstackhq/plugin-policy exec tsc --noEmitpasses🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests