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

fix(NODE-6144): Long.fromString incorrectly coerces valid inputs to Long.ZERO in special cases #677

Merged
merged 4 commits into from
May 1, 2024

Conversation

aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Apr 30, 2024

Description

What is changing?

Is there new documentation needed for these changes?

What is the motivation for this change?

Release Highlight

Long.fromString takes radix into account before coercing '+/-Infinity' and 'NaN' to Long.ZERO

Long.fromString no longer coerces the following cases to Long.ZERO when the provided radix supports all characters in the string:

  • '+Infinity', '-Infinity', or 'Infinity' when 35 <= radix <= 36
  • 'NaN' when 24 <= radix <= 36
// when writing in radix 27, 'n' and 'a' are valid characters, so 'NaN' represents the decimal number 17060
Long.fromString('NaN', 27); // new Long(17060)
Long.fromString('NaN', 10); // new Long(0) <-- Since 'NaN' is not a valid input in base 10, it gets coerced to Long.ZERO

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@aditi-khare-mongoDB aditi-khare-mongoDB changed the title fix(NODE-6144): Long.fromString coerces valid inputs to Long.ZERO in special cases fix(NODE-6144): Long.fromString incorrectly coerces valid inputs to Long.ZERO in special cases Apr 30, 2024
@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review April 30, 2024 21:55
@W-A-James W-A-James self-assigned this May 1, 2024
@W-A-James W-A-James added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label May 1, 2024
@W-A-James W-A-James self-requested a review May 1, 2024 15:21
src/long.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
3 participants