Backwards compatibility with latest release?
Closed this issue · 3 comments
This is totally on us with a bad decision, but out of curiosity, how hard would it be to make the latest change backwards compatible for Money objects stored in ETF Pre release?
KeyError: key :format_options not found in: #Money<:USD, 4497.81>
File "lib/money.ex", line 707, in Money.to_string/2
File "lib/money.ex", line 766, in Money.to_string!/2
🤦♂️
Ahhh, so this is coming from :erlang.binary_to_term/1
? Its a good point and its on me (too) since backwards compatibility is important. Let me do some experiments today and see if I can make that work.
I’m not sure it’s fair to say it’s on you - your library IS backwards compatible, it just makes the assumption that money structs are created with that version of the library (which feels very fair); we are doing some oddness on our end.
That said, if it’s an easy win it’d help us out or a jam, of sorts!
Thanks as always for the collaboration. It was an easy fix. Published ex_money version 5.5.1 with the following changelog entry:
Bug Fixes
- Fix formatting a
t:Money
that has no:format_options
key. That can happen if re-hydrating at:Money
using:erlang.binary_to_term/1
from an older version ofex_money
that doesn't have the:format_options
key in the struct. Thanks to @coladarci. Fixes #123.