Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c434539e32
ℹ️ 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".
| %{relationship_path: [first | _]}, query -> | ||
| relationship = Ash.Resource.Info.relationship(resource, first) | ||
| AshSql.Query.Projection.track_source(query, binding, relationship) |
There was a problem hiding this comment.
Disable projection pruning for manual aggregate relationships
When an aggregate is attached to a from_many? binding and its first relationship is manual, recording only source_attribute does not capture the callback's dependencies. AshSql.Aggregate.Lateral.apply_relationship_subquery/8 invokes the manual relationship callback directly without marking its accumulator unknown, unlike the manual join and EXISTS paths. For example, a manual count relationship that correlates using another parent column can have that column removed from the source subquery, causing a missing-column SQL error. Mark dependencies unknown for manual aggregate relationships rather than treating their declared source attribute as sufficient.
Useful? React with 👍 / 👎.
This replaces the implementation in ash-project/ash_sql#281, following the suggestion to collect required fields while building the query instead of scanning expressions at the end.
Each prunable
from_many?join gets a token. Field references and correlation keys are recorded against that token during query construction. The final pass uses this metadata to narrow implicit selections, without traversing expression ASTs or resolving aliases.When dependencies cannot be tracked reliably—including opaque SQL fragments, backend expressions, and
modify_querycallbacks—the original selection is retained. There is no AST-scanning fallback.The execution integration is in ash-project/ash_postgres#919.
Validation:
modify_query.