Given this embedded Ecto schema…
defmodule Foo do
use Ecto.Schema
embedded_schema do
field :state, Ecto.Enum, values: [:foo, :bar, :baz]
end
end
Loading data seems to work properly (i.e. properly cast string to atom for the enum field:
record = Ecto.embedded_load(Foo, %{state: "foo"}, :json)
%Foo{id: nil, state: :foo}
But dumping doesn’t do the reverse…
data = Ecto.embedded_dump(record, :json)
%{id: nil, state: :foo}
Notice state is still an atom.
I figured it might have something to do with the format (:json), but I’m not sure what else to use, the docs are not clear what the options are.
I have the same problem with user implemented Ecto.Types.
What am I missing? Thanks for the help!






















