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

Int32 size validation missing

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 1.0.7
    • 1.1.2
    • Bson, Shell API
    • None
    • Needed
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: