-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
ALL
The system.namespaces collection refer to collections with options with BSON 'undefined' values, which are translated to Javascript null. This can be confusing if you're querying using the $type operator. For example,
MongoDB shell version: 2.4.3 connecting to: 127.0.0.1:20000/test > db.version() 2.4.3 > db.testingnull.insert({"somefield":"hello", sub:{"sub1": null}}) > db.testingnull.find({"sub.sub1":{$type:10}}) { "_id" : ObjectId("519f9fdb9fe8e90bd386d522"), "somefield" : "hello", "sub" : { "sub1" : null } } > db.createCollection("test") { "ok" : 1 } > db.createCollection("test2") { "ok" : 1 } > db.system.namespaces.find({"options.create":{$type:2}}) { "name" : "test.test", "options" : { "create" : "test", "capped" : null, "size" : null } } { "name" : "test.test2", "options" : { "create" : "test2", "capped" : null, "size" : null } } > db.system.namespaces.find({"options.capped":{$type:10}}) > db.test.drop() true > db.test2.drop() true > db.system.namespaces.find({"options.capped":{$type:10}}) > db.createCollection("test",{capped:null}) { "ok" : 1 } > db.createCollection("test2",{capped:null}) { "ok" : 1 } > db.system.namespaces.find({"options.create":{$type:2}}) { "name" : "test.test", "options" : { "create" : "test", "capped" : null, "size" : null } } { "name" : "test.test2", "options" : { "create" : "test2", "capped" : null, "size" : null } } > db.system.namespaces.find({"options.capped":{$type:10}}) { "name" : "test.test", "options" : { "create" : "test", "capped" : null, "size" : null } } { "name" : "test.test2", "options" : { "create" : "test2", "capped" : null, "size" : null } }
As the Javascript interpreter does have an "undefined" type, the "capped" collection option should probably not translate the underlying "undefined" value to null.
- duplicates
-
SERVER-6102 Shell displays both 'undefined' and 'null' type as 'null'
- Closed