fix: preserve shared context in lateral join source queries#238
Merged
zachdaniel merged 1 commit intoJul 13, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes lateral-join query reconstruction so that caller-provided :shared context is preserved when rebuilding a lateral join source query, ensuring global preparations that depend on context.source_context[:shared] still receive that context during parent-path relationship traversal.
Changes:
- Refactors lateral join source query reconstruction into a dedicated helper (
rebuild_lateral_join_source_query/1) that carries forward:sharedwhile still normalizing:data_layercontext. - Adds a regression test that validates
:sharedcontext survives the rebuild and is visible to a preparation triggered via aparent()relationship path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/query.ex |
Uses a new helper to rebuild lateral join source queries while preserving :shared context and keeping existing :data_layer normalization behavior. |
test/query_test.exs |
Adds a regression test covering :shared context preservation through a parent() relationship path that triggers a preparation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
🚀 Thank you for your contribution! 🚀 |
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.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
Preserve the source query's
:sharedcontext when reconstructing a lateral join source query inAshSql.Query.set_context/4.Previously, the query was rebuilt from its resource with only the
:data_layercontext restored. This dropped:sharedbefore parent relationship paths were joined.Impact
The missing context affected relationship filters containing correlated
parent()expressions that traverse relationships on the parent resource.When a resource on that path had a global preparation depending on
context.source_context[:shared], the preparation ran without the caller-provided shared context.