Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
2.2.0
-
None
-
ALL
Description
The type conversion from ObjectId to String is invalid compared to previous MongoDB versions.
In Mongo 2.0.x:
var oid = new ObjectId("50575c152c2414982d000003");
|
var oidAsString = String(oid);
|
print(typeof oidAsString); // string
|
print(oidAsString); // 50575c152c2414982d000003
|
In Mongo 2.2.x:
var oid = new ObjectId("50575c152c2414982d000003");
|
var oidAsString = String(oid);
|
print(typeof oidAsString); // string
|
print(oidAsString); // ObjectId("50575c152c2414982d000003")
|
I would expect the converted value to be the hex string as described in 2.0.x.
This issue is similar to SERVER-5439, however, this is not an improvement but a bug.
Attachments
Issue Links
- is related to
-
DOCS-563 documentation for valueOf() and toString()
-
- Closed
-
- related to
-
DOCS-584 Release notes for 2.2 should mention breaking change: ObjectId().valueOf() and ObjectId().toString() have reversed meanings
-
- Closed
-
-
DOCS-586 Document "str" property of ObjectId() in JavaScript (shell and server)
-
- Closed
-
-
SERVER-2684 special types in shell (e.g. Timestamp) display in variety of ways, and can confuse users
-
- Closed
-