[SERVER-7055] ObjectId to String type conversion different in 2.2 from 2.0 Created: 17/Sep/12 Updated: 15/Feb/13 Resolved: 07/Oct/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | JavaScript |
| Affects Version/s: | 2.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Joe Gornick | Assignee: | Tad Marshall |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Description |
|
The type conversion from ObjectId to String is invalid compared to previous MongoDB versions. In Mongo 2.0.x:
In Mongo 2.2.x:
I would expect the converted value to be the hex string as described in 2.0.x. This issue is similar to |
| Comments |
| Comment by Tad Marshall [ 07/Oct/12 ] | |||
|
Hi Joe, Thanks for reporting this breaking change. We did change the behavior of the toString(), valueOf() and (indirectly) tojson() methods in version 2.2. The change was part of the fix for The workaround you discovered will be our documented way of dealing with this incompatibility between the versions; thanks for suggesting it! I filed
Sorry about the breakage; it was an attempt to make the API more uniform and it achieves that purpose, but it should have been flagged as a breaking change and workarounds should have been suggested. We don't expect to change it again, and we'll try to do a better job of announcing breaking changes like this in the release notes. Tad | |||
| Comment by Joe Gornick [ 17/Sep/12 ] | |||
|
A workaround I've found is to access the non-documented "str" property on an ObjectId.
|