You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One option might be to change Money.Ecto.Composite.Type#cast/1 to match the correct return value, while the alternative could be to have Cldr.Decimal return the same :error atom that comes back from Decimal.parse/1 (https://github.com/ericmj/decimal/blob/v2.0.0/lib/decimal.ex#L1177) and which Money.Ecto.Composite.Type#cast/1 already expects to handle. I'll be happy to submit a PR in either case.
The text was updated successfully, but these errors were encountered:
Hi 👋
Thanks for the great work on Money & CLDR!
I think there is a small bug in
Money.Ecto.Composite.Type#cast/1
: on L62 (https://github.com/kipcole9/money_sql/blob/master/lib/money/ecto/money_ecto_composite_type.ex#L62), the code callsCldr.Decimal.parse/1
and thewith
clause matches on{amount, ""}
, withelse
matching on{:error, {_, message}}
or:error
. However, when theamount
cannot be parsed,Cldr.Decimal.parse/1
returns{:error, amount}
(https://github.com/elixir-cldr/cldr_utils/blob/master/lib/cldr/decimal/decimal.ex#L34), which cannot match any of those.One option might be to change
Money.Ecto.Composite.Type#cast/1
to match the correct return value, while the alternative could be to haveCldr.Decimal
return the same:error
atom that comes back fromDecimal.parse/1
(https://github.com/ericmj/decimal/blob/v2.0.0/lib/decimal.ex#L1177) and whichMoney.Ecto.Composite.Type#cast/1
already expects to handle. I'll be happy to submit a PR in either case.The text was updated successfully, but these errors were encountered: