diff --git a/lib/ash/actions/create/bulk.ex b/lib/ash/actions/create/bulk.ex index c27825aad..ec59db580 100644 --- a/lib/ash/actions/create/bulk.ex +++ b/lib/ash/actions/create/bulk.ex @@ -472,6 +472,17 @@ defmodule Ash.Actions.Create.Bulk do }) ] + {:ok, result, notifications} -> + Process.put({:any_success?, ref}, true) + + store_notification(ref, notifications, opts) + + [ + Ash.Resource.set_metadata(result, %{ + bulk_create_index: changeset.context.bulk_create.index + }) + ] + {:error, error} -> store_error(ref, error, opts) [] @@ -498,6 +509,7 @@ defmodule Ash.Actions.Create.Bulk do Ash.DataLayer.transaction( List.wrap(resource) ++ action.touches_resources, fn -> + # TODO: check the difference bewteen ref handeling here and in bulk_update tmp_ref = make_ref() result = diff --git a/lib/ash/actions/destroy/bulk.ex b/lib/ash/actions/destroy/bulk.ex index 89ed1990e..d5baa3117 100644 --- a/lib/ash/actions/destroy/bulk.ex +++ b/lib/ash/actions/destroy/bulk.ex @@ -1385,6 +1385,24 @@ defmodule Ash.Actions.Destroy.Bulk do }) ] + {:ok, notifications} -> + Process.put({:any_success?, ref}, true) + + store_notification(ref, notifications, opts) + + [] + + {:ok, result, notifications} -> + Process.put({:any_success?, ref}, true) + + store_notification(ref, notifications, opts) + + [ + Ash.Resource.set_metadata(result, %{ + bulk_destroy_index: changeset.context.bulk_destroy.index + }) + ] + {:error, error} -> store_error(ref, error, opts) [] diff --git a/lib/ash/actions/update/bulk.ex b/lib/ash/actions/update/bulk.ex index 04866a1e5..da82b5e86 100644 --- a/lib/ash/actions/update/bulk.ex +++ b/lib/ash/actions/update/bulk.ex @@ -1679,6 +1679,17 @@ defmodule Ash.Actions.Update.Bulk do }) ] + {:ok, result, notifications} -> + Process.put({:any_success?, ref}, true) + + store_notification(ref, notifications, opts) + + [ + Ash.Resource.set_metadata(result, %{ + metadata_key => changeset.context |> Map.get(context_key) |> Map.get(:index) + }) + ] + {:error, error} -> store_error(ref, error, opts) []