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

Fix Decimal typecasting directly after setting. #37

Merged
merged 3 commits into from
Jun 1, 2022

Conversation

YannIsCoding
Copy link
Contributor

@YannIsCoding YannIsCoding commented May 19, 2022

Directly after setting a decimal attribute, the attribute reader return a String instead of a BigDecimal.

These changes check if the typecasting is correct in the writer method and force the attribute reader to read the value before typecast if it's not.

Note that these changes only affect the scenario when the attribute is read directly after being saved. The behavior when loading data from the DB was correct and is left unchanged.

More details:
#34

Directly after setting a decimal attribute, the attribute reader return a String instead of a BigDecimal.

This changes force the attribute reader to read the value before typecast when it has not yet been saved.

More details:
#34
Improve Decimal typecasting
test/serialized_attributes_test.rb Outdated Show resolved Hide resolved
lib/serialize_attributes/store.rb Outdated Show resolved Hide resolved
lib/serialize_attributes/store.rb Show resolved Hide resolved
@YannIsCoding
Copy link
Contributor Author

@nickcampbell18 Are you happy with this? Should I merge?

@YannIsCoding YannIsCoding merged commit 0e93b68 into main Jun 1, 2022
@YannIsCoding YannIsCoding deleted the bug/serialize_bigdecimal branch June 1, 2022 14:50
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

Successfully merging this pull request may close these issues.

2 participants