-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MONGOID-5213 Document changes to BigDecimal type and addition of global flag #5126
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
Conversation
not find the string for that ``BigDecimal``, since the query is looking for a | ||
``BigDecimal``. In order to query for that string, the ``BigDecimal`` must | ||
first be converted to a string with ``to_s``. Note that this is not a problem | ||
when the field has type ``BigDecimal``. |
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.
Would BigDecimal
-typed field have the same issue in the other direction - when querying existing data that is stored as strings after Mongoid.map_big_decimal_to_decimal128
is set to true, nothing would be found?
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.
Yes that is true as well... How would you like to handle this case?
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.
It should be documented in the release notes and options documentation for map_big_decimal_to_decimal128
. It should make clear that when switching the flag, it will break the ability to query against existing data, and that all data must be migrated.
Fortunately, in the real-world, applications are very unlikely to be doing any queries on BigDecimal as string today, because it's pretty useless--you'd can only match against exact values. In other worlds, if you have field :money_amt, type: BigDecimal
, then .gt(money_amt: 100)
will NOT work today. The valid cases are:
.where(money_amt: 100)
--> pretty unlikely to do for money-type use cases..ne(money_amt: nil)
--> will work regardless of string or decimal128.
Hence this migration should be easy in practice. (I use BigDecimal on at least 50 fields in my app and I don't have any queries against it; I only use it for persisting data which is retrieved via other queries.)
docs/reference/fields.txt
Outdated
The ``BigDecimal`` field type is used to store numbers with increased precision. | ||
|
||
The ``BigDecimal`` field type stores its values in two different ways under the | ||
hood, depending on the value of the ``Mongoid.map_big_decimal_to_decimal128`` |
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.
under the hood
--> in the database
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.
I kind of like it the way it is tbh...
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.
"Under the hood":
- Does not clearly indicate under which "hood" -- is it in Ruby's memory or the database?
- Is idiomatic English which does not make sense to non-native speakers (Mongoid is not a car :) )
It's good to think about these points when writing technical documentation.
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.
Alright, if you really think so I'll change it
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.
done
docs/reference/fields.txt
Outdated
|
||
.. note:: | ||
In Mongoid 7.6, the global config ``Mongoid.map_big_decimal_to_decimal128`` | ||
will be defaulted to true instead of false. |
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.
Following Semver, this default change should take place in Mongoid 8.0, NOT 7.6
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 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.
Read this article: https://serpapi.com/blog/how-a-routine-gem-update-ended-up-charging/ and tell me your thoughts. Also please read the SemVer spec https://semver.org/
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.
Hey we've seen this and we're reconsidering how we want to version this... Thanks!
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.
👍
* master: MONGOID-5098 Bug fix: Range.mongoize should mongoize its members (mongodb#5108) MONGOID-5212 Support for Decimal128 type (mongodb#5125) MONGOID-5213 Document changes to BigDecimal type and addition of global flag (mongodb#5126) MONGOID-5209 Document "Custom Field Options" functionality + various docs improvements (mongodb#5120) MONGOID-5193 rails 7 support (mongodb#5122) Fix default topology name - should be standalone (mongodb#5130) Update MRSS (mongodb#5129) MONGOID-5207 Test Ruby 3.1 on Evergreen (mongodb#5123) MONGOID-5186 .with_scope should restore previous scope (mongodb#5127) MONGOID-5161 - [Documentation Only] Clarify the policy for working with . and $ named fields which were introduced in MongoDB 5.0 (mongodb#5051)
* master: (48 commits) MONGOID-5098 Bug fix: Range.mongoize should mongoize its members (mongodb#5108) MONGOID-5212 Support for Decimal128 type (mongodb#5125) MONGOID-5213 Document changes to BigDecimal type and addition of global flag (mongodb#5126) MONGOID-5209 Document "Custom Field Options" functionality + various docs improvements (mongodb#5120) MONGOID-5193 rails 7 support (mongodb#5122) Fix default topology name - should be standalone (mongodb#5130) Update MRSS (mongodb#5129) MONGOID-5207 Test Ruby 3.1 on Evergreen (mongodb#5123) MONGOID-5186 .with_scope should restore previous scope (mongodb#5127) MONGOID-5161 - [Documentation Only] Clarify the policy for working with . and $ named fields which were introduced in MongoDB 5.0 (mongodb#5051) MONGOID-5173 Specs should use bang (!) methods (without describe/context change) (mongodb#5109) Fix doc syntax RUBY-2783 Require bson 4-stable for Mongoid as bson master is 5.0 and not compatible with driver (mongodb#5113) MONGOID-5208 fix error on reloading nil embedded document (mongodb#5116) MONGOID-5206 fix bug where embedded document is not re-embedded (mongodb#5115) MONGOID-5207 Add Ruby 3.1 to GH Actions (mongodb#5114) MONGOID-5207 Use YAML.safe_load in specs (mongodb#5112) MONGOID-5199 Reloadable#reload_embedded_document doesn't respect session (mongodb#5105) Fix MONGOID-5198 Calling children_changed? on a deep cyclical data structure will cause semi-infinite looping (mongodb#5104) MONGOID-5203 Add all available auth_mech options to Configuration documentation (mongodb#5103) ...
Uh oh!
There was an error while loading. Please reload this page.