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
Improve BigDecimal mongoize behavior #4164
Conversation
One more note here, since |
I've raised MONGOID-4165 to track this. |
@@ -22,18 +70,29 @@ | |||
end | |||
end | |||
|
|||
context "when the value is a float" do | |||
context "when the the value is true" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's an extra 'the' here
Hi @johnnyshields |
3ecfc00
to
e37535a
Compare
@estolfo done. Travis CI running now, looks like it should be good. |
thanks! |
Object.new | ||
end | ||
|
||
it "returns true" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should say false
- `demongoize` should always return a BigDecimal or else nil, never an empty string - `mongoize` should always return a String which can be demongoized to a BigDecimal, otherwise or nil - The strings `"Infinity"` and `"-Infinity"` now evaluate as numeric true. - `BigDecimal`s now evaluate as numeric true. - Additional tests for BigDecimal covering all edge cases. - Fix typo "the the" in all specs / comments in repo
e37535a
to
d879ee3
Compare
@estolfo I fixed all the notes you raised. |
thanks! |
Recently I attempted to migrate a number of
Float
fields toBigDecimal
, and I found that the behavior is inconsistent between the two. This PR rectifies that situation. Note thatBigDecimal
is stored in MongoDB as a string, as there is no native BSON type for it.demongoize
should always return a BigDecimal or else nil, never an empty string (this mirrors how Floats and Integers behave).mongoize
should always return a String which can be demongoized to a BigDecimal, otherwise nil"Infinity"
and"-Infinity"
in the database."Infinity"
and"-Infinity"
now evaluate as numeric? true.BigDecimal
s now evaluate as numeric? true.Demongoize
Mongoize