_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
Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
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 ); }