Skip to content

Mongo Decimal128 values with extreme exponents read back as strings of thousands of digits #30461

Open

Description

@wmadden-electric

What a user sees. A Decimal128 field reads back as decimal text without an exponent, so the text is stable across a round trip and matches the PostgreSQL numeric codec. For a value near the limits of Decimal128 (exponents down to 1E-6176 and up to 1E+6144) that text is a plain digit string of up to about 6,100 characters. Nothing is wrong with the value; the string is just very long.

Where. decimal128Decode and the text normalisation in packages/3-mongo-target/1-mongo-target/src/core/bson-scalar-helpers.ts.

Likely fix. None for now: the JSON form must carry no exponent, and no user has reported this. If it shows up in practice, options are a length limit that refuses such values with a clear message, or an opt-in exponent form.

Where it came from. Accepted when the Decimal128 codec was added in #30396.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions