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

feat: add parse mode #37

Merged
merged 1 commit into from
Feb 19, 2025
Merged

feat: add parse mode #37

merged 1 commit into from
Feb 19, 2025

Conversation

quagmt
Copy link
Owner

@quagmt quagmt commented Feb 17, 2025

Description

Introduced ParseMode, offering different behaviors for parsing string numbers into udecimal.Decimal:

  • ParseModeError (default): returns an error if the total digits after the decimal point exceed the default precision.
  • ParseModeTrunc: allows strings with any number of digits after the decimal point to be parsed into udecimal.Decimal. Excess digits will be truncated (not rounded).

Why is this feature required?

  • When data from a database or an external API has more digits than the allowed precision, parsing it into udecimal.Decimal returns an error, preventing the use of udecimal.Decimal and its high performance capabilities in those cases.
  • ParseModeTrunc resolves this issue by allowing some precision loss, if acceptable.

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.23%. Comparing base (751d5a2) to head (376075b).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #37      +/-   ##
==========================================
+ Coverage   96.19%   96.23%   +0.03%     
==========================================
  Files           5        5              
  Lines        1892     1910      +18     
==========================================
+ Hits         1820     1838      +18     
  Misses         48       48              
  Partials       24       24              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@quagmt quagmt force-pushed the feat/add-parse-mode branch from 7c0da73 to 376075b Compare February 17, 2025 13:07
@quagmt quagmt merged commit 89217c6 into master Feb 19, 2025
9 checks passed
@quagmt quagmt deleted the feat/add-parse-mode branch February 19, 2025 12:58
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.

1 participant