fix(codegen-ts): stripPackage relationship @objectRef in projection join resolver#94
Merged
Merged
Conversation
…oin resolver A projection aggregate that traverses a relationship whose @objectref is package-qualified (pkg::Entity) silently dropped the join — and with it every aggregate column traversing that join — leaving the generated view with only PK + passthrough columns. Root cause: buildJoinTree resolved the relationship target via root.findObject(targetName) on the RAW objectRef, but findObject keys on the bare name (as the @via / @Of / @from paths already account for via stripPackage). The directory loader qualifies a same-package objectRef even when authored bare, so real directory-loaded models hit this while the string-loaded test fixture (bare objectRef) did not. Fix: stripPackage(targetName) before findObject. Adds a regression test with a package-qualified @objectref asserting the inverse-FK join + count aggregate survive. Full codegen-ts suite green (865 tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DV7ad8tggzcpFJzXYvHwRU
dmealing
force-pushed
the
fix/projection-qualified-objectref-join
branch
from
June 29, 2026 23:44
c748129 to
eef9870
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A projection aggregate that traverses a relationship whose
@objectRefispackage-qualified (
pkg::Entity) silently dropped the join — and with itevery aggregate column traversing that join — leaving the generated view with
only PK + passthrough columns. No error; the view just degraded.
Root cause
buildJoinTree(extract-view-spec.ts) resolved the relationship target withroot.findObject(targetName)on the raw@objectRef, butfindObjectkeys onthe bare name (which is why the
@via/@of/@frompaths alreadystripPackagefirst). The directory loader qualifies a same-package@objectRefeven when authored bare (
Week→acme::Week), so real directory-loaded models hitthis while the existing string-loaded test fixture (bare objectRef) did not — the
qualified path was never exercised.
When the target failed to resolve, the join path
breaks out empty, so the join treehas no entry for that relationship;
buildSelectSpecthencontinues past anyaggregate whose
@of/@viaentity isn't in the join tree.Fix
stripPackage(targetName)beforefindObject, matching the sibling resolution paths.Tests
buildProjectionViews — package-qualified relationship @objectRef: a projection over a relationship with a package-qualified@objectRefasserts the inverse-FK
LEFT OUTER JOIN+COUNT(DISTINCT …) AS week_countsurvive.Red before the fix (view emitted PK only), green after.
🤖 Generated with Claude Code