Closed emaiax closed 3 years ago
Having field defaults in a schema seems to be broken or unsupported.
schema "my table" do field :value, Money.Ecto.Composite.Type, default: Money.new(:BRL, 0) end
Example:
Assertion with == failed code: assert bc_november.value == Money.new(:BRL, 0) left: %Money{amount: #Decimal<0>, currency: :BRL, format_options: [{:default, #Money<:BRL, 0>}]} right: %Money{amount: #Decimal<0>, currency: :BRL, format_options: []}
Shouldn't we support https://hexdocs.pm/ecto/Ecto.Schema.html#field/3 options as well? default at least. Mostly because even if the value isn't given, it defaults to something.
default
I'd more than happy to fix this. 👍
Having field defaults in a schema seems to be broken or unsupported.
Example:
Shouldn't we support https://hexdocs.pm/ecto/Ecto.Schema.html#field/3 options as well?
default
at least. Mostly because even if the value isn't given, it defaults to something.I'd more than happy to fix this. 👍