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

Change _massageObject string processing

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.3.11
    • None
    • Shell
    • None
    • Fully Compatible
    • Build B (10/30/15), Build C (11/20/15), Platforms 2016-08-26

    Description

      _massageObject (used by db.foo.find() and db.foo.remove()) converts a 24 char string into { _id: "..." }. Surely the intention behind the length == 24 check is to convert the string into the corresponding ObjectId()?

      src/mongo/shell/collection.js:134-158

       DBCollection.prototype._massageObject = function( q ){
           if ( ! q )
               return {};
       
           var type = typeof q;
       
           if ( type == "function" )
               return { $where : q };
       
           if ( q.isObjectId )
               return { _id : q };
       
           if ( type == "object" )
               return q;
       
           if ( type == "string" ){
               if ( q.length == 24 )
      -            return { _id : q };
      +            return { _id : ObjectId( q ) };
       
               return { $where : q };
           }
       
           throw Error( "don't know how to massage : " + type );
       
       }
      

      Attachments

        Activity

          People

            matt.cotter Matt Cotter
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: