Fix nested selected link joins#27
Conversation
Plan selected single-link joins recursively so nested result shapes use the parent selected alias as the join source. Preserve parent rows under optional selected sources by lowering descendant joins to LEFT joins. Assisted-by: Codex:gpt-5.5
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c7e67f23c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Assign planner-owned SQL aliases to repeated nested selected links and reuse the alias plan across joins, selected values, and result-shape references. Assisted-by: Codex:gpt-5.5
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48dda43463
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Reserve root path aliases before assigning nested selected link SQL aliases so selected joins do not collide with filter or ordering joins synthesized from the root source. Assisted-by: Codex:gpt-5.5
Keep Many cardinality distinct from optional source nullability so unsupported multi-link selected shapes do not get planned as single-link joins. Assisted-by: Codex:gpt-5.5
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 991cd76e33
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Pre-reserve root selected link aliases while assigning selected-shape SQL aliases so nested selected links cannot claim aliases needed by later root selected joins. Assisted-by: Codex:gpt-5.5
Add root path aliases to the join alias allocator reservation set so generated selected-link aliases cannot reuse aliases synthesized by root-relative filter or order paths. Assisted-by: Codex:gpt-5.5
|
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |



Summary
Fix nested selected single-link shape planning so descendant selected links join from the selected parent alias instead of the root source, while keeping SQL aliases unique when selected link names repeat or collide with root-relative path aliases.
Closes #26
Scope
sqlite-query-plan.Manycardinality distinct from nullable parent sources so unsupported multi-link shapes do not get lowered as single-link joins.LEFT JOINfor descendant selected joins under optional selected sources so root rows are preserved.Post.author.best_friendand repeatedUser.best_friend.best_friendnested selection.Spec and plan alignment
List the
spec/andplan/files checked for this change. If the changeintentionally diverges from them, explain why and include the required document
update in this pull request.
spec/query.md: selected relation fields require nested shapes, and the query pipeline must preserve nested result shapes.spec/sqlite-query-plan.md: SQLite Plan owns aliases, joins, selected value slots, result-shaping metadata, andinner/leftjoin choices for required and optional links. Multi-link nested shapes are specified for follow-up planning rather than single-link joins.plan/sqlite-query-plan-implementation-plan.md: the change stays insidesqlite-query-planand keeps SQL string rendering insqlite-query-sqlgen.Tests
List the automated and manual checks performed.
cargo test --workspacecargo test -p sqlite-query-plan sqlite_select_plan_can_join_nested_selected_single_linkcargo test -p sqlite-query-plan sqlite_select_plan_uses_left_join_for_nested_selected_link_under_optional_sourcecargo test -p sqlite-query-plan sqlite_select_plan_uses_unique_aliases_for_repeated_nested_selected_link_namescargo test -p sqlite-query-plan sqlite_select_plan_avoids_root_path_alias_collision_with_nested_selected_linkcargo test -p sqlite-query-plan sqlite_select_plan_preserves_multi_link_cardinality_under_optional_sourcecargo test --test select_execution select_pipeline_executes_nested_selected_single_link_shapecargo test --test select_execution select_pipeline_executes_repeated_nested_selected_single_link_namesReview notes
Call out API boundaries, temporary rules, migration concerns, or follow-up work
that reviewers should inspect closely.
AI assistance
Disclose AI tool usage according to
AI_POLICY.md.messages with
Assisted-bytrailers.Tools and models: