Skip to content

fix(core): resolve navigation-only nodes in template fragments - #365

Merged
zantvoort merged 1 commit into
mainfrom
fix/template-fragment-ref-traversal
Aug 3, 2026
Merged

fix(core): resolve navigation-only nodes in template fragments#365
zantvoort merged 1 commit into
mainfrom
fix/template-fragment-ref-traversal

Conversation

@zantvoort

Copy link
Copy Markdown
Collaborator

Fixes #364.

A navigation-only node (a path that navigates beyond a Ref foreign key) interpolated into a query builder template fragment was not resolved to a column. It fell through to parameter compilation, so the raw metamodel object reached the JDBC driver (Type NavigableSiteMetamodel$7 not supported type on MariaDB, NotSerializableException on H2). The predicate form and full select templates already handled the same path.

Changes

  • QueryModelImpl.resolveElements now resolves Navigable column nodes the same way TemplatePreparation.resolveElements does: full metamodels pass through, navigation-only nodes are rebuilt into resolvable runtime metamodels via Metamodel.of(root, fieldPath). Table-level paths get the same error message as the main template path.
  • The nested TemplateString value walker in TemplatePreparation.collectReferencedTablePaths records the referenced path for Navigable column nodes, so the joins beyond the reference are derived for template fragments. Without this, the resolved column failed with Alias for table not found.
  • RefGraphTraversalIntegrationTest.testFilterThroughRefInWhereTemplate compares the template fragment form against the predicate form; it reproduced both failure layers before the fix.

Verification

./mvnw -pl storm-foundation,storm-core test: 2501 tests, 0 failures.

Copilot AI review requested due to automatic review settings August 3, 2026 11:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes query builder template fragments so that “navigation-only” paths (i.e., Navigable nodes produced when traversing beyond a Ref) are resolved to column references instead of falling through to bind-parameter compilation, aligning fragment behavior with full templates and predicate-style filters.

Changes:

  • Updated QueryModelImpl.resolveElements to treat Navigable column nodes like columns by rebuilding navigation-only nodes into resolvable runtime Metamodel instances via Metamodel.of(root, fieldPath).
  • Updated TemplatePreparation.collectReferencedTablePaths to record referenced paths for Navigable column nodes in template fragment values so join derivation works beyond Ref.
  • Added an integration test ensuring where(raw(...)) fragment behavior matches the predicate form for a beyond-Ref column path.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
storm-core/src/main/java/st/orm/core/template/impl/QueryModelImpl.java Resolves Navigable column nodes in template fragment values into Elements.Column via a rebuilt runtime Metamodel.
storm-core/src/main/java/st/orm/core/template/impl/TemplatePreparation.java Collects referenced table paths for Navigable column nodes inside template fragment values to derive required joins.
storm-core/src/test/java/st/orm/core/RefGraphTraversalIntegrationTest.java Adds regression coverage comparing fragment-style where(raw(...)) against predicate-style filtering across a Ref.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zantvoort
zantvoort merged commit 872c318 into main Aug 3, 2026
8 checks passed
@zantvoort
zantvoort deleted the fix/template-fragment-ref-traversal branch August 3, 2026 12:02
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.

Navigation beyond a Ref degrades to a bind parameter in query builder template fragments

2 participants