fix: handle nil in atomic array casting

This commit is contained in:
Zach Daniel 2024-08-06 07:11:56 -04:00
parent 58065c31cd
commit 960af4b887

View file

@ -1585,6 +1585,8 @@ defmodule Ash.Type do
end end
@impl true @impl true
def apply_atomic_constraints_array(nil, _), do: {:ok, nil}
def apply_atomic_constraints_array(new_value, constraints) when is_list(new_value) do def apply_atomic_constraints_array(new_value, constraints) when is_list(new_value) do
new_value new_value
|> Enum.reduce_while({:ok, []}, fn val, {:ok, vals} -> |> Enum.reduce_while({:ok, []}, fn val, {:ok, vals} ->
@ -1620,6 +1622,10 @@ defmodule Ash.Type do
end end
end end
def cast_atomic_array(nil, _) do
{:atomic, nil}
end
def cast_atomic_array(new_value, _constraints) do def cast_atomic_array(new_value, _constraints) do
{:not_atomic, "Cannot cast a non-literal list atomically"} {:not_atomic, "Cannot cast a non-literal list atomically"}
end end