Skip to content

Commit 14635a5

Browse files
committed
only skip before_transactin in helper
the other hooks are run as part of the action itself and have their own validity checks
1 parent 9144f27 commit 14635a5

File tree

4 files changed

+7
-25
lines changed

4 files changed

+7
-25
lines changed

lib/ash/actions/create/bulk.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,6 @@ defmodule Ash.Actions.Create.Bulk do
487487
else
488488
batch
489489
end
490-
|> Enum.reject(fn
491-
%{valid?: false} = changeset ->
492-
store_error(ref, changeset, opts)
493-
true
494-
495-
_changeset ->
496-
false
497-
end)
498490

499491
{batch, must_be_simple_results} =
500492
batch

lib/ash/actions/destroy/bulk.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,14 +1439,6 @@ defmodule Ash.Actions.Destroy.Bulk do
14391439
else
14401440
batch
14411441
end
1442-
|> Enum.reject(fn
1443-
%{valid?: false} = changeset ->
1444-
store_error(ref, changeset, opts)
1445-
true
1446-
1447-
_changeset ->
1448-
false
1449-
end)
14501442

14511443
{batch, must_be_simple_results} =
14521444
Ash.Actions.Helpers.split_and_run_simple(

lib/ash/actions/helpers.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ defmodule Ash.Actions.Helpers do
1717
Enum.reduce(batch, {[], []}, fn changeset, {batch, must_be_simple} ->
1818
if changeset.around_transaction in [[], nil] and changeset.after_transaction in [[], nil] and
1919
changeset.around_action in [[], nil] do
20-
changeset = Ash.Changeset.run_before_transaction_hooks(changeset)
20+
changeset =
21+
if changeset.valid? do
22+
Ash.Changeset.run_before_transaction_hooks(changeset)
23+
else
24+
changeset
25+
end
26+
2127
{[changeset | batch], must_be_simple}
2228
else
2329
{batch, [%{changeset | __validated_for_action__: action.name} | must_be_simple]}

lib/ash/actions/update/bulk.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,14 +1757,6 @@ defmodule Ash.Actions.Update.Bulk do
17571757
else
17581758
batch
17591759
end
1760-
|> Enum.reject(fn
1761-
%{valid?: false} = changeset ->
1762-
store_error(ref, changeset, opts)
1763-
true
1764-
1765-
_changeset ->
1766-
false
1767-
end)
17681760

17691761
{batch, must_be_simple_results} =
17701762
Ash.Actions.Helpers.split_and_run_simple(

0 commit comments

Comments
 (0)