WIP: Improved support for CQL Decimal - #376
Draft
dehall wants to merge 5 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a work-in-progress of improved support for CQL Decimal. It's not quite ready for a thorough line-by-line review because I still need to review edge cases and do some cleanup, but I don't expect any fundamental changes at this point.
This PR migrates Decimals from being represented by plain JS
numberto being represented by aDecimalclass. (CQL Integers remain represented by plain JS numbers.) Our newDecimalclass is a wrapper around the decimal.js library, all interactions with the library are limited to one file so if we decide that's the wrong approach, we only have to change one file.Where possible, I've tried to make the changes developer-friendly, for instance, because
Quantity.valueis always a Decimal, theQuantityconstructor accepts anything that can be converted to a Decimal, eg, a number, bigint, or string. This is primarily relevant to the unit tests where we have a lot of "result should equal(new Quantity(3, 'g')" style test expectations.The two unit test failures are expected at this point (I removed the part of the
expand Intervallogic that covers those 2 specific tests) but I'm waiting for more direction on #cql > Interval Expand example before doing anything more on that front.Notable Boundaries
There are a couple instances where interactions with plain JS numbers are forced:
luxon, specifically the timezoneOffset fieldnumberanywayPull requests into cql-execution require the following.
Submitter and reviewer should ✔ when done.
For items that are not-applicable, mark "N/A" and ✔.
Submitter:
npm run checkto run tests, lint, and prettier)Reviewer:
Name: