Commit 32ca3b5
authored
fix: flatten nested calculation/aggregate maps before wrapping in subquery for aggregates (#206)
When keyset pagination is combined with a relationship sort and loaded
aggregates, the query's select contains nested maps like
`%{calculations: %{__calc__0: expr}}`. Ecto doesn't allow nested maps
in subquery selects, causing an error.
This fix reuses `AshSql.Query.rewrite_nested_selects/1` (already used in
`distinct.ex` and `query.ex` for the same purpose) to flatten these
nested maps before creating the subquery in `wrap_in_subquery_for_aggregates`.
Fixes the failing test in ash-project/ash_postgres#6771 parent 2eb94a3 commit 32ca3b5
1 file changed
+32
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2548 | 2548 | | |
2549 | 2549 | | |
2550 | 2550 | | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
2551 | 2569 | | |
2552 | 2570 | | |
2553 | 2571 | | |
| |||
2556 | 2574 | | |
2557 | 2575 | | |
2558 | 2576 | | |
2559 | | - | |
2560 | | - | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
2561 | 2581 | | |
2562 | 2582 | | |
2563 | 2583 | | |
| |||
2572 | 2592 | | |
2573 | 2593 | | |
2574 | 2594 | | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
2575 | 2605 | | |
2576 | 2606 | | |
2577 | 2607 | | |
| |||
0 commit comments