Skip to content

Commit

Permalink
fix: add checks for around_transaction and around_action in bulk (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam authored Sep 24, 2024
1 parent a1473bb commit ad3c690
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/ash/actions/create/bulk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ defmodule Ash.Actions.Create.Bulk do
)
end)
|> Enum.reduce({[], []}, fn changeset, {batch, must_be_simple} ->
if changeset.after_transaction in [[], nil] do
if changeset.around_transaction in [[], nil] and changeset.after_transaction in [[], nil] and
changeset.around_action in [[], nil] do
changeset = Ash.Changeset.run_before_transaction_hooks(changeset)
{[changeset | batch], must_be_simple}
else
Expand Down
3 changes: 2 additions & 1 deletion lib/ash/actions/destroy/bulk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,8 @@ defmodule Ash.Actions.Destroy.Bulk do

{batch, must_be_simple} =
Enum.reduce(batch, {[], []}, fn changeset, {batch, must_be_simple} ->
if changeset.after_transaction in [[], nil] do
if changeset.around_transaction in [[], nil] and changeset.after_transaction in [[], nil] and
changeset.around_action in [[], nil] do
changeset = Ash.Changeset.run_before_transaction_hooks(changeset)
{[changeset | batch], must_be_simple}
else
Expand Down
2 changes: 1 addition & 1 deletion lib/ash/changeset/changeset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ defmodule Ash.Changeset do
around_action: [around_action_fun | {around_action_fun, map}],
around_transaction: [around_transaction_fun | {around_transaction_fun, map}],
attributes: %{optional(atom) => any},
before_action: [before_action_fun | {around_action_fun, map}],
before_action: [before_action_fun | {before_action_fun, map}],
before_transaction: [before_transaction_fun | {before_transaction_fun, map}],
context: map,
filter: Ash.Filter.t() | nil,
Expand Down

0 comments on commit ad3c690

Please sign in to comment.