Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast function used to return error when currency is nil #24

Closed
frahugo opened this issue Jul 7, 2022 · 2 comments
Closed

Cast function used to return error when currency is nil #24

frahugo opened this issue Jul 7, 2022 · 2 comments

Comments

@frahugo
Copy link

frahugo commented Jul 7, 2022

Upgraded to version 1.6 and a condition is not handled in the money_sql code:

iex(1) > Money.Ecto.Composite.Type.cast(%{amount: "10", currency: nil})  
** (CondClauseError) no cond clause evaluated to a truthy value
    (digital_token 0.4.0) lib/digital_token.ex:142: DigitalToken.validate_token/1
    (ex_money 5.12.0) lib/money.ex:2280: Money.do_validate_currency/2
    (ex_money 5.12.0) lib/money.ex:211: Money.new/3
    (ex_money_sql 1.6.0) lib/money/ecto/money_ecto_composite_type.ex:96: Money.Ecto.Composite.Type.cast/2

Prior to 1.6, it was returning:

iex(1) > Money.Ecto.Composite.Type.cast(%{amount: "10", currency: nil})
{:error, [message: "The currency nil is invalid"]}
@kipcole9
Copy link
Owner

kipcole9 commented Jul 7, 2022

Thanks for the report and apolgies for the regression. As of commit 070b4c I believe the issue is fixed.

I have published ex_money_sql version 1.7.1 with the fix.

Thanks again for the report.

@frahugo
Copy link
Author

frahugo commented Jul 7, 2022

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants