chore: get build passing

This commit is contained in:
Zach Daniel 2024-06-23 17:44:02 -04:00
parent 85b928b0d9
commit e17fa8a1c5
2 changed files with 30 additions and 29 deletions

View file

@ -45,8 +45,7 @@ defmodule Ash.Actions.Update.Bulk do
fully_atomic_changeset =
cond do
!Enum.empty?(query.before_action) ->
{:not_atomic,
"cannot atomically update a query if it has `before_action` hooks"}
{:not_atomic, "cannot atomically update a query if it has `before_action` hooks"}
not_atomic_reason ->
{:not_atomic, not_atomic_reason}
@ -195,7 +194,8 @@ defmodule Ash.Actions.Update.Bulk do
# having after action hooks. Or perhaps we need to stream the ids and then bulk update
# them.
opts =
if has_after_batch_hooks? || !Enum.empty?(atomic_changeset.after_action) || opts[:notify?] do
if has_after_batch_hooks? || !Enum.empty?(atomic_changeset.after_action) ||
opts[:notify?] do
Keyword.put(opts, :return_records?, true)
else
opts
@ -478,32 +478,36 @@ defmodule Ash.Actions.Update.Bulk do
{results, []}
end
{results, errors, error_count, notifications} =
if Enum.empty?(atomic_changeset.after_action) do
{results, [], 0, notifications}
else
Enum.reduce(results, {[], [], 0, notifications}, fn result, {results, errors, error_count, notifications} ->
case Ash.Changeset.run_after_actions(result, atomic_changeset, []) do
{:error, error} ->
if opts[:transaction] && opts[:rollback_on_error?] do
if Ash.DataLayer.in_transaction?(atomic_changeset.resource) do
Ash.DataLayer.rollback(
atomic_changeset.resource,
error
)
end
{results, errors, error_count, notifications} =
if Enum.empty?(atomic_changeset.after_action) do
{results, [], 0, notifications}
else
Enum.reduce(results, {[], [], 0, notifications}, fn result,
{results, errors, error_count,
notifications} ->
case Ash.Changeset.run_after_actions(result, atomic_changeset, []) do
{:error, error} ->
if opts[:transaction] && opts[:rollback_on_error?] do
if Ash.DataLayer.in_transaction?(atomic_changeset.resource) do
Ash.DataLayer.rollback(
atomic_changeset.resource,
error
)
end
end
{results, errors ++ List.wrap(error), error_count + Enum.count(List.wrap(error)), notifications}
{results, errors ++ List.wrap(error),
error_count + Enum.count(List.wrap(error)), notifications}
{:ok, result, _changeset, %{notifications: more_new_notifications}} ->
{[result | results], errors, error_count, notifications ++ more_new_notifications}
end
end)
|> then(fn {results, errors, error_count, notifications} ->
{Enum.reverse(results), errors, error_count, notifications}
end)
end
{:ok, result, _changeset, %{notifications: more_new_notifications}} ->
{[result | results], errors, error_count,
notifications ++ more_new_notifications}
end
end)
|> then(fn {results, errors, error_count, notifications} ->
{Enum.reverse(results), errors, error_count, notifications}
end)
end
{results, errors, error_count} =
case load_data(

View file

@ -605,9 +605,6 @@ defmodule Ash.Changeset do
{:not_atomic, reason} ->
{:not_atomic, reason}
{:error, error} ->
{:error, error}
changeset ->
clear_phase(changeset)
end