fix(orm): use raw alias for join keys when PK/FK has field access policy#2675
fix(orm): use raw alias for join keys when PK/FK has field access policy#2675lsmith77 wants to merge 1 commit into
Conversation
|
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 (5)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds detection and selection of raw column aliases for PK/FK fields with conditional read policies, and updates join-pair construction and dialect join filters (lateral + SQLite) to use those raw aliases; includes regression tests covering three ChangesFix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/orm/src/client/crud/dialects/sqlite.tsOops! Something went wrong! :( ESLint: 9.29.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by packages/orm/src/client/crud/dialects/lateral-join-dialect-base.tsOops! Something went wrong! :( ESLint: 9.29.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by packages/plugins/policy/src/policy-handler.tsOops! Something went wrong! :( ESLint: 9.29.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by
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 |
022e5dd to
c109d4a
Compare
c109d4a to
531e8d1
Compare
fix #2674
When a PK or FK field carries a
@denyor@allowfield-level policy, thepolicy handler wraps it in
CASE WHEN … THEN NULL. This causedincludetosilently return empty arrays because join conditions evaluated as
fk = NULL.Fix: Two-part:
The policy handler emits a
__zs_raw_<field>alias (the raw column value)alongside the potentially-nulled expression for any PK or FK field that has
a field access policy.
Join condition builders (
buildJoinPairs, SQLite'sbuildRelationJoinFilter,M2M path in the lateral-join dialect) use the raw alias selectively:
ownedByModel = false): raw alias on both sides — the child'sFK may be denied to hide which parent it belongs to, but the parent must
still be able to fetch its children.
ownedByModel = true): raw alias only on the relation's PKside; the FK side stays as a plain ref. Denying the FK is designed to hide
the relation entirely (preserves pre-existing behavior verified by
field-level-policy.test.ts).Regression tests added in
tests/regression/test/issue-2674.test.ts.Note:
externalIdMappingin the issue title is a REST API option unrelated tothe fix; the root cause is purely at the ORM layer.
Summary by CodeRabbit