Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5212

Implement transparent storage of BigDecimal values as Decimal128

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 8.0.1
    • Affects Version/s: None
    • Component/s: Attributes
    • Labels:
      None
    • Fully Compatible

      Implementation plan:

      • store BigDecimal values as Decimal128 (requires bson-4.14)
      • when loading values, decode both Decimal128 and strings in the database to BigDecimal instances. This is always possible because BigDecimal has unlimited range and precision.
      • both bson 4.14+ and bson 5 will be supported
      • field type could be set to BSON::Decimal128 to avoid conversions to/from BigDecimal if it is desired to preserve Decimal128 types or to guarantee persistability since not every BigDecimal can be stored as Decimal128

      Note that the data will be lazily converted to Decimal128 in the database upon saves.

      Documentation
      Migration guidance
      Specify what happens when out of range BigDecimal is attempted to be persisted
      Specify BSON::Decimal128 type explicitly to avoid converting to BigDecimal

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: