You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calculations do not to load when loading aggregate #191
I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.
Versions
I was able to isolate a reproduction of this issue when upgrading:
ash_sql 0.3.11 => 0.3.12
Operating system
macOS Sonoma
Current Behavior
When ash_sql processes a query with:
Aggregates (which require subquery wrapping)
Calculations that depend on relationships
Pagination with count: true
Something in the calculation loading pipeline fails. The calculations are added to query.calculations but aren't properly transferred through the pagination/counting transformation, resulting in #Ash.NotLoaded fields in the app
Reproduction
Sample query:
MyApp.Client|>Ash.Query.for_read(:read)|>Ash.Query.load([# aggregate:most_recent_payment_date,# calculation depending on relationship:active_subscription_processor,active_subscription: [:payment_processor]])|>Ash.Query.page(limit: 50,offset: 0,count: true)
When reading this query, the most_recent_payment_date and active_subscription_processor will not be loaded even though they should be.
This is a standalone .exs script that reproduces the issues I found with loading calculations with aggregates.
It requires a local test postgres database to exercise ash_sql.
Activity
[-]Calculations fail to load when loading aggregate[/-][+]Calculations do not to load when loading aggregate[/+]zachdaniel commentedon Nov 15, 2025
related: elixir-ecto/ecto#4680
zachdaniel commentedon Nov 16, 2025
Fixed in
main