[SERVER-9817] Collection options with value of BSON 'undefined' are translated to Javascript null (in the shell?) Created: 30/May/13  Updated: 30/May/13  Resolved: 30/May/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Stephen Lee Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-6102 Shell displays both 'undefined' and '... Closed
Operating System: ALL
Participants:

 Description   

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.


Generated at Thu Feb 08 03:21:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.