-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.6.0-rc1
-
Component/s: None
-
None
-
ALL
The documents can still be queried but the field cannot be indexed.
ren@ren-desktop ~/mongo-copy $ ./mongo --writeMode legacy MongoDB shell version: 2.6.0-rc1-pre- connecting to: test > db.user.drop() true > db.user.insert({ a: { "": 2 }}) > db.user.find() { "_id" : ObjectId("531f798aa676eb5ad3d44332"), "a" : { "" : 2 } } > db.user.insert( { "": 2 }) > db.user.find() { "_id" : ObjectId("531f798aa676eb5ad3d44332"), "a" : { "" : 2 } } { "_id" : ObjectId("531f7a27a676eb5ad3d44333"), "" : 2 }
Shell session continued, using write commands
ren@ren-desktop ~/mongo-copy $ ./mongo MongoDB shell version: 2.6.0-rc1-pre- connecting to: test > db.user.insert( { "": 3 }) WriteResult({ "nInserted" : 1 }) > db.user.find() { "_id" : ObjectId("531f798aa676eb5ad3d44332"), "a" : { "" : 2 } } { "_id" : ObjectId("531f7a27a676eb5ad3d44333"), "" : 2 } { "_id" : ObjectId("531f7a3248b214d47bdddd04"), "" : 3 } > db.user.update({ }, { "": 4 }) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.user.find() { "_id" : ObjectId("531f798aa676eb5ad3d44332"), "" : 4 } { "_id" : ObjectId("531f7a27a676eb5ad3d44333"), "" : 2 } { "_id" : ObjectId("531f7a3248b214d47bdddd04"), "" : 3 } > db.user.ensureIndex({ "": 1 }) WriteResult({ "nInserted" : 0, "writeError" : { "code" : 67, "errmsg" : "bad index key pattern { : 1.0 }: Index keys cannot be an empty field." } }) > db.user.ensureIndex({ "a.": 1 }) WriteResult({ "nInserted" : 0, "writeError" : { "code" : 67, "errmsg" : "bad index key pattern { a.: 1.0 }: Index keys cannot contain an empty field." } }) > db.user.find({ "": 3 }) { "_id" : ObjectId("531f7a3248b214d47bdddd04"), "" : 3 }
- duplicates
-
SERVER-6852 Disallow empty path components in documents and queries
- Backlog
- related to
-
SERVER-11812 Can create indexes on invalid fields (empty, $** component)
- Closed