From d56937aeb6eddf097267a5624d5a5b37b3569003 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 23 May 2023 10:42:12 -0400 Subject: [PATCH] fix: properly wrap errored changesets in `{:error` in bulk creates --- lib/ash/actions/create/bulk.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ash/actions/create/bulk.ex b/lib/ash/actions/create/bulk.ex index 76ef9990..820e4ecd 100644 --- a/lib/ash/actions/create/bulk.ex +++ b/lib/ash/actions/create/bulk.ex @@ -345,7 +345,7 @@ defmodule Ash.Actions.Create.Bulk do {:error, notifications, error} -> if opts[:stop_on_error?] do - {:halt, {[], error}} + {:halt, {notify_stream([], notifications, resource, action, opts), error}} else {error |> List.wrap() @@ -355,7 +355,11 @@ defmodule Ash.Actions.Create.Bulk do {:ok, invalid, notifications} -> if opts[:stop_on_error?] && !Enum.empty?(invalid) do - {:halt, {[], invalid}} + {:halt, + {[], + invalid + |> Stream.map(&{:error, &1}) + |> notify_stream(notifications, resource, action, opts)}} else {invalid |> Stream.map(&{:error, &1})