From 113b8740d40abdbfe983653ea83525096356d592 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 29 Nov 2022 16:21:53 -0500 Subject: [PATCH] chore: hotfix code_interface change --- lib/ash/code_interface.ex | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/ash/code_interface.ex b/lib/ash/code_interface.ex index 7cde759b..8f0bd8e2 100644 --- a/lib/ash/code_interface.ex +++ b/lib/ash/code_interface.ex @@ -20,15 +20,15 @@ defmodule Ash.CodeInterface do @doc false def default_value(resource, action, key) do - field = + {field_type, field} = case Enum.find(action.arguments, fn argument -> argument.name == key end) do nil -> - Ash.Resource.Info.attribute(resource, key) + {:attribute, Ash.Resource.Info.attribute(resource, key)} argument -> - argument + {:argument, argument} end if !field.allow_nil? do @@ -36,14 +36,18 @@ defmodule Ash.CodeInterface do end default = - if action.type == :update || (action.type == :destroy && action.soft?) do - if is_nil(action.update_default) do - field.default - else - field.update_default - end - else + if field_type == :argument do field.default + else + if action.type == :update || (action.type == :destroy && action.soft?) do + if is_nil(action.update_default) do + field.default + else + field.update_default + end + else + field.default + end end if is_function(default) do