-
Type: Sub-task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: BSON
Use Case
As a... driver engineer
I want... to add a fromStringWithRounding static method to Decimal128
So that... users can construct Decimal128 instances that make use of our previously existing inexact rounding behaviour
User Impact
Will require users who were depending on the non-spec compliant rounding behaviour in previous versions to change their code to make use of Decimal128.fromStringWithRounding. This will also make it possible for users relying on this behaviour to migrate to v6 of the driver.
Dependencies
- N/A
Unknowns
- Do we want to go the extra mile and factor out common behaviour from fromString and fromStringWithRounding or are we alright with fully duplicating logic here?
- This would clean up the code and make it easier for other engineers to work with in future, but would also take a little longer to implement and have a slight performance impact due to the increased number of function calls required.
- Yes, we want to keep our code as clean as we can where possible
Acceptance Criteria
Implementation Requirements
- Pull in commit from user-provided fix in parent ticket and ensure they get credit this way if possible. Otherwise, ensure they are mentioned in the release notes.
- Rename the method pulled in to fromStringWithRounding
- convert fromString and fromStringWithRounding to wrapper methods for an internal method that conditionally performs inexact rounding based on a flag passed in by the wrapper methods.
Testing Requirements
- pull in user-provided tests from PR in parent ticket
- Add tests that ensure we don't throw on inexact rounding cases
- test that we round up correctly when rounding digit is >= 5
- test that we round down when rounding digit is < 5
- Run non-rounding related spec tests with fromStringWithRounding
Documentation Requirements
- Release notes describing feature, ensuring that user gets credit
- API documentation for fromStringWithRounding should include examples of numbers affected and expected results.
Follow Up Requirements
- N/A