mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: remove belongs to related after action
This commit is contained in:
parent
a3ee29c433
commit
80cedce2a2
1 changed files with 77 additions and 67 deletions
|
@ -235,21 +235,6 @@ defmodule Ash.Actions.ManagedRelationships do
|
|||
|
||||
case data do
|
||||
{:ok, data} ->
|
||||
current_value = Map.get(data, relationship.name)
|
||||
|
||||
case delete_unused(
|
||||
data,
|
||||
List.wrap(current_value),
|
||||
relationship,
|
||||
[],
|
||||
[],
|
||||
changeset,
|
||||
actor,
|
||||
opts
|
||||
) do
|
||||
{:ok, _, new_instructions} ->
|
||||
instructions = new_instructions ++ instructions
|
||||
|
||||
if input in [nil || []] do
|
||||
{:cont, {changeset, instructions}}
|
||||
else
|
||||
|
@ -303,10 +288,35 @@ defmodule Ash.Actions.ManagedRelationships do
|
|||
)
|
||||
end
|
||||
end
|
||||
|> case do
|
||||
{:cont, {changeset, instructions}} ->
|
||||
changeset =
|
||||
Ash.Changeset.after_action(changeset, fn _, result ->
|
||||
current_value = Map.get(data, relationship.name)
|
||||
|
||||
case delete_unused(
|
||||
data,
|
||||
List.wrap(current_value),
|
||||
relationship,
|
||||
[],
|
||||
[],
|
||||
changeset,
|
||||
actor,
|
||||
opts
|
||||
) do
|
||||
{:ok, _, new_instructions} ->
|
||||
{:ok, result, new_instructions}
|
||||
|
||||
{:error, error} ->
|
||||
{:halt, {Ash.Changeset.add_error(changeset, error), instructions}}
|
||||
end
|
||||
end)
|
||||
|
||||
{:cont, {changeset, instructions}}
|
||||
|
||||
{:halt, other} ->
|
||||
{:halt, other}
|
||||
end
|
||||
|
||||
{:error, error} ->
|
||||
{:halt, {Ash.Changeset.add_error(changeset, error), instructions}}
|
||||
|
|
Loading…
Reference in a new issue