Skip to content

Commit

Permalink
Don't include changes for related changests that are marked for deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Dec 10, 2016
1 parent 4c8cde5 commit ebdf13c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/ecto/exceptions.ex
Expand Up @@ -113,9 +113,14 @@ defmodule Ecto.InvalidChangesetError do

defp extract_changes(%Ecto.Changeset{changes: changes}) do
Enum.reduce(changes, %{}, fn({key, value}, acc) ->
Map.put(acc, key, extract_changes(value))
case value do
%Ecto.Changeset{action: :delete} -> acc
_ -> Map.put(acc, key, extract_changes(value))
end
end)
end
defp extract_changes([%Ecto.Changeset{action: :delete} | tail]),
do: [extract_changes(tail)]
defp extract_changes([%Ecto.Changeset{} = changeset | tail]),
do: [extract_changes(changeset) | extract_changes(tail)]
defp extract_changes(other),
Expand Down

0 comments on commit ebdf13c

Please sign in to comment.