From ee509394a9ca651240a2f4fe40a6784be02936ce Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Sun, 13 Oct 2024 19:21:49 -0400 Subject: [PATCH] chore: handle nil action in `atomic_update` --- lib/ash/changeset/changeset.ex | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ash/changeset/changeset.ex b/lib/ash/changeset/changeset.ex index f557a31aa..c6b5189f2 100644 --- a/lib/ash/changeset/changeset.ex +++ b/lib/ash/changeset/changeset.ex @@ -1680,7 +1680,11 @@ defmodule Ash.Changeset do {:ok, value} -> allow_nil? = - attribute.allow_nil? and attribute.name not in changeset.action.require_attributes + if is_nil(changeset.action) do + true + else + attribute.allow_nil? and attribute.name not in changeset.action.require_attributes + end if is_nil(value) and !allow_nil? do add_required_attribute_error(changeset, attribute) @@ -1707,8 +1711,7 @@ defmodule Ash.Changeset do changeset else allow_nil? = - attribute.allow_nil? and - (is_nil(changeset.action) || attribute.name not in changeset.action.require_attributes) + attribute.allow_nil? and attribute.name not in changeset.action.require_attributes value = if allow_nil? || not Ash.Expr.can_return_nil?(value) do