mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: prepare change with nil
old value on union type change
This commit is contained in:
parent
839937bf6e
commit
352e27a153
1 changed files with 15 additions and 0 deletions
|
@ -734,6 +734,21 @@ defmodule Ash.Type.Union do
|
|||
end
|
||||
end
|
||||
|
||||
def prepare_change(
|
||||
%Ash.Union{},
|
||||
%Ash.Union{type: type_name, value: new_value},
|
||||
constraints
|
||||
) do
|
||||
with {:ok, type_configs} <- Keyword.fetch(constraints, :types),
|
||||
{:ok, type_config} <- Keyword.fetch(type_configs, type_name),
|
||||
{:ok, type} <- Keyword.fetch(type_config, :type),
|
||||
type_constraints <- Keyword.get(type_config, :constraints, []),
|
||||
type <- Ash.Type.get_type(type),
|
||||
{:ok, value} <- type.prepare_change(nil, new_value, type_constraints) do
|
||||
{:ok, %Ash.Union{type: type_name, value: value}}
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_change(%Ash.Union{type: type_name, value: old_value}, new_value, constraints)
|
||||
when is_map(new_value) do
|
||||
constraints
|
||||
|
|
Loading…
Reference in a new issue