Results are inconsistent
// With insert the empty field is created. > db.foo.insert({'': 'not allowed'}) WriteResult({ "nInserted" : 1 }) > db.foo.find() { "_id" : ObjectId("5314b690dd98b8b9decc41a7"), "" : "not allowed" } > db.foo.drop() true // Replace-style upsert allows "" field names > db.foo.find() { "_id" : ObjectId("5314b7b03a6a695da8595d60") } > db.foo.drop() true > db.foo.update({}, {'': 'not allowed'}, {upsert:true}) WriteResult({ "nMatched" : 0, "nUpserted" : 1, "nModified" : 0, "_id" : ObjectId("5314b7d03a6a695da8595d61") }) > db.foo.find() { "_id" : ObjectId("5314b7d03a6a695da8595d61"), "" : "not allowed" } // Other upserts don't allow empty fields: > db.foo.drop() true > db.foo.update({'': 'not allowed'}, {$set:{a:1}}, {upsert:true}) WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0, "writeError" : { "code" : 56, "errmsg" : "An empty update path is not valid." } }) > db.foo.drop() false > db.foo.update({}, {$set:{"":1}}, {upsert:true}) WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0, "writeError" : { "code" : 56, "errmsg" : "An empty update path is not valid." } })
- duplicates
-
SERVER-6852 Disallow empty path components in documents and queries
- Backlog