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

Int32 size validation missing

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.0.7
    • Fix Version/s: 1.1.2
    • Component/s: Bson, Shell API
    • Labels:
      None
    • Documentation Changes:
      Needed
    • Documentation Changes Summary:
      Not sure if documentation changes are actually needed, but {{Int32(n)}} will now truncate {{n}} and only use the least significant 32 bits of it when it is outside the 32-bit signed integer range.

      Description

      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

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              dave.cuthbert Dave Cuthbert
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: