diff --git a/lib/ash/actions/load.ex b/lib/ash/actions/load.ex index a5a03a24..844a7a04 100644 --- a/lib/ash/actions/load.ex +++ b/lib/ash/actions/load.ex @@ -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) diff --git a/lib/ash/filter/filter.ex b/lib/ash/filter/filter.ex index 68c28c8f..335cff84 100644 --- a/lib/ash/filter/filter.ex +++ b/lib/ash/filter/filter.ex @@ -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