mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 13:03:02 +12:00
chore: fix recent calculation optimization to never prune authorization calcs
This commit is contained in:
parent
7991d84b0b
commit
5b40040c76
2 changed files with 16 additions and 10 deletions
|
@ -2041,8 +2041,10 @@ defmodule Ash.Actions.Read.Calculations do
|
|||
Enum.filter(calculations_in_query, &used?(ash_query, &1.name))}
|
||||
end
|
||||
|
||||
defp used?(_ash_query, {:__ash_fields_are_visible__, _}), do: true
|
||||
|
||||
defp used?(ash_query, name) do
|
||||
Map.has_key?(ash_query, name) ||
|
||||
Map.has_key?(ash_query.calculations, name) ||
|
||||
Enum.any?(ash_query.context[:calculation_dependencies] || [], fn {_source, dest} ->
|
||||
name in dest
|
||||
end)
|
||||
|
|
|
@ -676,16 +676,20 @@ defmodule Ash.Actions.Read do
|
|||
record
|
||||
|
||||
record ->
|
||||
Map.update!(record, :calculations, fn calculations ->
|
||||
Map.update!(calculations, name, fn value ->
|
||||
Ash.Type.rewrite(
|
||||
type,
|
||||
value,
|
||||
[{:cleanup_field_auth, further_load}],
|
||||
constraints
|
||||
)
|
||||
if Map.has_key?(record.calculations, name) do
|
||||
Map.update!(record, :calculations, fn calculations ->
|
||||
Map.update!(calculations, name, fn value ->
|
||||
Ash.Type.rewrite(
|
||||
type,
|
||||
value,
|
||||
[{:cleanup_field_auth, further_load}],
|
||||
constraints
|
||||
)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
else
|
||||
record
|
||||
end
|
||||
end
|
||||
|
||||
nil ->
|
||||
|
|
Loading…
Reference in a new issue