Maybe_mark_for_deletion if there is no data

The changeset has new field (that should be created) and at the same time it is marked for deletion,

this results in an error that says cannot delete .. because there is nothing to delete in the first place, how can I prevent this from happening?

def maybe_mark_for_deletion(changeset) do
  if get_change(changeset, :delete) do
    %{changeset | action: :delete}
  else
    changeset
  end
end

Can you give us an example of the map before it’s gone into this function please.

I can explain further, I have a parent changeset that contains a child changeset.

the parent changeset have the action :delete the child changeset have the action :insert