Why does this fail:
%Partner{} |> cast(%{id: 123}, [:id]) |> delete
with a Ecto.NoPrimaryKeyValueError
? I'm setting the primary key explicitly?
Why does this fail:
%Partner{} |> cast(%{id: 123}, [:id]) |> delete
with a Ecto.NoPrimaryKeyValueError
? I'm setting the primary key explicitly?
Copyright © 2021 Jogjafile Inc.
For changesets, the
id
from the original struct (data
) is used byRepo.delete
, and not the one inchanges
, andcast
puts the newid
only inchanges
. You can either mergechanges
into the original struct (data
):or put the
id
into%Partner{}
manually: