improvement: allow for parent/1 expressions to be resolved "later"

This commit is contained in:
Zach Daniel 2023-07-26 18:50:20 -04:00
parent bda7c56543
commit f1f1aa8a6e
2 changed files with 26 additions and 16 deletions

View file

@ -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)

View file

@ -3025,9 +3025,8 @@ 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
@ -3045,6 +3044,7 @@ defmodule Ash.Filter do
other
end
end
end
def do_hydrate_refs(
%Ash.Query.Exists{expr: expr, at_path: at_path, path: path} = exists,