-
-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Code of Conduct
- I agree to follow this project's Code of Conduct
AI Policy
- 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.
- Test 1 will succeed.
- Test 2 will fail. I believe this is a reproduction of Ecto.QueryError: when loading aggregates in the query with Ash.Query.load #190
- Test 3 will fail. This is the reported issue here.
Expected Behavior
I expect the calculations, relationships, and aggregates to load.
For now, I am working around this issue by pinning ash_sql to 0.3.11