mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: hide __metadata__ field on inspect
fix: load relationships required for calculations (optimize later)
This commit is contained in:
parent
1e124295ed
commit
786047c3e7
2 changed files with 15 additions and 3 deletions
|
@ -662,7 +662,19 @@ defmodule Ash.Actions.Load do
|
|||
defp read(query, action) do
|
||||
action = action || primary_read(query)
|
||||
|
||||
Ash.Actions.Read.unpaginated_read(query, action)
|
||||
query
|
||||
|> load_for_calcs()
|
||||
|> Ash.Actions.Read.unpaginated_read(action)
|
||||
end
|
||||
|
||||
defp load_for_calcs(query) do
|
||||
Enum.reduce(query.calculations || %{}, query, fn {_, calc}, query ->
|
||||
calc.module.load(
|
||||
query,
|
||||
calc.opts,
|
||||
Map.put(calc.context, :context, query.context)
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
defp primary_read(query) do
|
||||
|
|
|
@ -31,7 +31,7 @@ defmodule Ash.Schema do
|
|||
|
||||
field(:aggregates, :map, virtual: true, default: %{})
|
||||
field(:calculations, :map, virtual: true, default: %{})
|
||||
field(:__metadata__, :map, virtual: true, default: %{})
|
||||
field(:__metadata__, :map, virtual: true, default: %{}, redact: true)
|
||||
|
||||
for aggregate <- Ash.Resource.Info.aggregates(__MODULE__) do
|
||||
{:ok, type} = Aggregate.kind_to_type(aggregate.kind, :string)
|
||||
|
@ -86,7 +86,7 @@ defmodule Ash.Schema do
|
|||
|
||||
field(:aggregates, :map, virtual: true, default: %{})
|
||||
field(:calculations, :map, virtual: true, default: %{})
|
||||
field(:__metadata__, :map, virtual: true, default: %{})
|
||||
field(:__metadata__, :map, virtual: true, default: %{}, redact: true)
|
||||
|
||||
for aggregate <- Ash.Resource.Info.aggregates(__MODULE__) do
|
||||
{:ok, type} = Aggregate.kind_to_type(aggregate.kind, :string)
|
||||
|
|
Loading…
Reference in a new issue