gjaldon / ecto_enum

Ecto extension to support enums in models
MIT License
562 stars 131 forks source link

Enum value not loaded correctly after update/insert #3

Closed zipme closed 8 years ago

zipme commented 8 years ago

It seems the Ecto.Type's load callback is not invoked, when I insert or update an record with integer or string type instead of atom, the result of Repo.insert!/1 or Repo.update/1 would be integer/string instead of atom.

defenum MyApp.Status,
  pending: 0

defmodule MyApp.Order do
  field :status, OrderStatus, default: :pending
end

order = Repo.insert! %Order{status: 0}
IO.inspect order.status # => 0

I am using ecto 1.1.1 and ecto_enum 0.3.0.

zipme commented 8 years ago

This seems to be related to this issue https://github.com/elixir-lang/ecto/issues/345

gjaldon commented 8 years ago

@zipme feel free to reopen if this is still a problem.