Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1006

Int32 size validation missing

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.1.2
    • Affects Version/s: 1.0.7
    • Component/s: Bson, Shell API
    • Labels:
      None
    • Needed
    • Hide

      Not sure if documentation changes are actually needed, but Int32 will now truncate n and only use the least significant 32 bits of it when it is outside the 32-bit signed integer range.

      Show
      Not sure if documentation changes are actually needed, but Int32 will now truncate n and only use the least significant 32 bits of it when it is outside the 32-bit signed integer range.

      Problem Statement/Rationale

      https://jira.mongodb.org/browse/SERVER-59765 added a check if values passed to $dateAdd / $dateSubtract would overflow. The update works correctly with numbers cast to Long, but fails with values cast using Int32 

      Steps to Reproduce

      Run the following:
      db.addSub.aggregate([{$project: {newDate: {"$dateAdd":
      {"startDate" : Timestamp(0, 4294967295),
      "unit" : "month",
      "amount" : {$multiply: [Int32("2147483648")]},
      "timezone" : "+1187" }}
      }} ])

      Expected Results

      The value passed to Int32 is outside the signed range, it should be rejected 

       

      Actual Results

      The value is accepted. 

      Additional Notes

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            dave.cuthbert@mongodb.com Dave Cuthbert (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: