Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-32072

DBRef with NumberInt ID changing to float in the shell

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 3.2.7, 3.4.10, 3.6.0-rc4
    • Fix Version/s: 3.6.3, 3.7.2
    • Component/s: Shell
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v3.6, v3.4, v3.2
    • Steps To Reproduce:
      Hide

      Run the following commands from the shell or as shell scripts

      • Step 1

        //insert a new row
        var currentId= ObjectId();
        db.test.insert({ 
            "_id" : currentId, 
            "string" : "1", 
            "int" : NumberInt(9087), 
            "float" : 1.1, 
            "refLong" : DBRef("ReferenceList", NumberLong(9087), "Reference"), 
            "refInt" : DBRef("ReferenceList", NumberInt(9087), "Reference")
        });
        

      • STEP2

        //fetch the row and save it again
        var doc = db.test.findOne({_id:currentId});
        //doc.refInt.$id = NumberInt(row.refInt.$id);
        db.test.save(doc);
        

      Show
      Run the following commands from the shell or as shell scripts Step 1 //insert a new row var currentId= ObjectId(); db.test.insert({ "_id" : currentId, "string" : "1" , "int" : NumberInt(9087), "float" : 1.1, "refLong" : DBRef( "ReferenceList" , NumberLong(9087), "Reference" ), "refInt" : DBRef( "ReferenceList" , NumberInt(9087), "Reference" ) }); STEP2 //fetch the row and save it again var doc = db.test.findOne({_id:currentId}); //doc.refInt.$id = NumberInt(row.refInt.$id); db.test.save(doc);
    • Sprint:
      Platforms 2018-02-12

      Description

      I have a issue when fetching and saving documents in the shell have a DBRef id that is a NumberInt

      If you insert this document and then view the document json is fine

      { 
          "_id" : ObjectId(), 
          "string" : "1", 
          "int" : NumberInt(9087), 
          "float" : 1.1, 
          "refLong" : DBRef("ReferenceList", NumberLong(9087), "Reference"), 
          "refInt" : DBRef("ReferenceList", NumberInt(9087), "Reference")
      }

      But if you run a shell script that finds the document and then saves it again, the field "refInt" changes from

      • "refInt" : DBRef("ReferenceList", NumberInt(9087), "Reference")
        To
      • "refInt" : DBRef("ReferenceList", 9087.0, "Reference")

      The field "int" does not change

      I have checked a few versions and have the same issue

      When running the steps to reproduce, if you run only step one, the data is fine, if you run Step 2, dbref id changes from int to float

        Attachments

          Activity

            People

            Assignee:
            jason.carey Jason Carey
            Reporter:
            plasticsnake simon hall
            Participants:
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: