Closed jadlr closed 8 years ago
Prior to timex_ecto 3 you could do:
timex_ecto
iex(1)> Timex.Ecto.Date.cast(%{"day" => "15", "month" => "8", "year" => "2016"}) {:ok, #<Date(2016-08-15)>}
The same input will result in an error in timex_ecto 3:
iex(1)> Timex.Ecto.Date.cast(%{"day" => "15", "month" => "8", "year" => "2016"}) ** (Protocol.UndefinedError) protocol Timex.Protocol not implemented for %{"day" => "15", "month" => "8", "year" => "2016"} (timex) lib/protocol.ex:1: Timex.Protocol.impl_for!/1 (timex) lib/protocol.ex:30: Timex.Protocol.to_date/1 (timex_ecto) lib/types/date.ex:28: Timex.Ecto.Date.cast/1
see https://github.com/bitwalker/timex_ecto/blob/3.0.3/lib/types/date.ex#L28
This is because Timex.to_date/1 is tried before Ecto.Date.cast/1. Is the new behaviour wanted or should it still be possible to cast from a string map?
Timex.to_date/1
Ecto.Date.cast/1
timex master now implements Timex.Protocol for maps. Should not be a problem in the future.
Timex.Protocol
Prior to
timex_ecto
3 you could do:The same input will result in an error in
timex_ecto
3:see https://github.com/bitwalker/timex_ecto/blob/3.0.3/lib/types/date.ex#L28
This is because
Timex.to_date/1
is tried beforeEcto.Date.cast/1
. Is the new behaviour wanted or should it still be possible to cast from a string map?