mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 13:03:02 +12:00
Fix generated change/3
function when only implementing batch_change/3
(#1415)
This commit is contained in:
parent
55f1ead24f
commit
4a75743812
2 changed files with 3 additions and 8 deletions
|
@ -213,7 +213,7 @@ defmodule Ash.Resource.Change do
|
|||
Ash.Changeset.before_action(changeset, fn changeset ->
|
||||
{[changeset], notifications} =
|
||||
Enum.split_with(
|
||||
before_batch([changeset], opts, context),
|
||||
apply(__MODULE__, :before_batch, [[changeset], opts, context]),
|
||||
fn %Ash.Notifier.Notification{} ->
|
||||
false
|
||||
end
|
||||
|
@ -224,14 +224,13 @@ defmodule Ash.Resource.Change do
|
|||
else
|
||||
changeset
|
||||
end
|
||||
|> Ash.Changeset.before_action(changeset, fn change ->
|
||||
|> Ash.Changeset.before_action(fn changeset ->
|
||||
Enum.at(batch_change([changeset], opts, context), 0)
|
||||
end)
|
||||
|> then(fn changeset ->
|
||||
if has_after_batch?() do
|
||||
Ash.Changeset.after_action(changeset, fn changeset, result ->
|
||||
[{changeset, result}]
|
||||
|> after_batch(opts, context)
|
||||
apply(__MODULE__, :after_batch, [[{changeset, result}], opts, context])
|
||||
|> Enum.reduce({[], [], []}, fn item, {records, errors, notifications} ->
|
||||
case item do
|
||||
{:ok, record} -> {[record | records], errors, notifications}
|
||||
|
|
|
@ -18,10 +18,6 @@ defmodule Ash.Test.Actions.BulkCreateTest do
|
|||
defmodule AddAfterToTitle do
|
||||
use Ash.Resource.Change
|
||||
|
||||
def change(_, _, _) do
|
||||
raise "can't get here"
|
||||
end
|
||||
|
||||
def batch_change(changesets, _, _) do
|
||||
changesets
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue