Skip to content

fix(codegen-ts): stripPackage relationship @objectRef in projection join resolver#94

Merged
dmealing merged 1 commit into
mainfrom
fix/projection-qualified-objectref-join
Jun 29, 2026
Merged

fix(codegen-ts): stripPackage relationship @objectRef in projection join resolver#94
dmealing merged 1 commit into
mainfrom
fix/projection-qualified-objectref-join

Conversation

@dmealing

Copy link
Copy Markdown
Member

Problem

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. No error; the view just degraded.

Root cause

buildJoinTree (extract-view-spec.ts) resolved the relationship target with
root.findObject(targetName) on the raw @objectRef, but findObject keys on
the bare name (which is why the @via / @of / @from paths already
stripPackage first). The directory loader qualifies a same-package @objectRef
even when authored bare
(Weekacme::Week), so real directory-loaded models hit
this 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 tree
has no entry for that relationship; buildSelectSpec then continues past any
aggregate whose @of/@via entity isn't in the join tree.

Fix

stripPackage(targetName) before findObject, matching the sibling resolution paths.

Tests

  • New regression test under buildProjectionViews — package-qualified relationship @objectRef: a projection over a relationship with a package-qualified @objectRef
    asserts the inverse-FK LEFT OUTER JOIN + COUNT(DISTINCT …) AS week_count survive.
    Red before the fix (view emitted PK only), green after.
  • Full codegen-ts suite green (865 tests).

🤖 Generated with Claude Code

…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
dmealing force-pushed the fix/projection-qualified-objectref-join branch from c748129 to eef9870 Compare June 29, 2026 23:44
@dmealing
dmealing merged commit 936e187 into main Jun 29, 2026
11 checks passed
@dmealing
dmealing deleted the fix/projection-qualified-objectref-join branch June 29, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant