mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
improvement: allow for parent/1
expressions to be resolved "later"
This commit is contained in:
parent
bda7c56543
commit
f1f1aa8a6e
2 changed files with 26 additions and 16 deletions
|
@ -336,6 +336,16 @@ defmodule Ash.Actions.Load do
|
|||
value ->
|
||||
Map.put(record, name, value |> List.wrap() |> Enum.at(0))
|
||||
end
|
||||
|
||||
:error ->
|
||||
case value do
|
||||
%{__lateral_join_source__: destination_value} when not is_nil(destination_value) ->
|
||||
source_value ==
|
||||
destination_value
|
||||
|
||||
value ->
|
||||
Map.put(record, name, value |> List.wrap() |> Enum.at(0))
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -3025,24 +3025,24 @@ defmodule Ash.Filter do
|
|||
|
||||
def do_hydrate_refs(%Ash.Query.Parent{expr: expr} = this, context) do
|
||||
if !Map.has_key?(context, :parent_stack) || context.parent_stack in [[], nil] do
|
||||
raise "Attempted to use parent expression without a known parent: #{inspect(this)}"
|
||||
end
|
||||
{:ok, this}
|
||||
else
|
||||
context =
|
||||
%{
|
||||
context
|
||||
| resource: hd(context.parent_stack),
|
||||
root_resource: hd(context.parent_stack),
|
||||
parent_stack: tl(context.parent_stack)
|
||||
}
|
||||
|> Map.put(:relationship_path, [])
|
||||
|
||||
context =
|
||||
%{
|
||||
context
|
||||
| resource: hd(context.parent_stack),
|
||||
root_resource: hd(context.parent_stack),
|
||||
parent_stack: tl(context.parent_stack)
|
||||
}
|
||||
|> Map.put(:relationship_path, [])
|
||||
case do_hydrate_refs(expr, context) do
|
||||
{:ok, expr} ->
|
||||
{:ok, %{this | expr: expr}}
|
||||
|
||||
case do_hydrate_refs(expr, context) do
|
||||
{:ok, expr} ->
|
||||
{:ok, %{this | expr: expr}}
|
||||
|
||||
other ->
|
||||
other
|
||||
other ->
|
||||
other
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue