Skip to content

Commit

Permalink
fix: simplify and fix path generation for nested relationship path deps
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Jan 15, 2025
1 parent a3c3491 commit 057b074
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/ash/actions/read/calculations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -842,20 +842,16 @@ defmodule Ash.Actions.Read.Calculations do
match?({:__calc_dep__, _}, calculation.name)
end)
|> Enum.flat_map(fn {_calc_name, calculation} ->
relationship = calculation.opts[:relationship]
query = calculation.opts[:query]

query
|> get_all_rewrites(top_calculation, path)
|> Enum.map(fn {{path, data, calc_name, calc_load}, source} ->
{{path ++ [{:rel, relationship}], data, calc_name, calc_load}, source}
end)
get_all_rewrites(
calculation.opts[:query],
top_calculation,
path ++ [{:rel, calculation.opts[:relationship]}]
)
end)
end

# TODO: This currently must assume that all relationship loads are different if
# authorize?: true, because the policies have not yet been applied.
#

def split_and_load_calculations(
domain,
Expand Down

0 comments on commit 057b074

Please sign in to comment.