[SERVER-68967] Convert BSONType into an enum class rather than a raw enum Created: 18/Aug/22 Updated: 14/Aug/23 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Charlie Swanson | Assignee: | Backlog - Storage Execution Team |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Storage Execution
|
| Participants: |
| Description |
|
This would have major fallout across the codebase, but I think would improve things. I was just recently authoring a patch and ran across the following strange behavior. The correct way to build a BSON object with MinKey and MaxKey for testing is like so:
But this code actually compiles also:
After several minutes or maybe an hour of insanity, I realized that when I typed the second one I had actually constructed this object:
because it was reading from the BSONType enum and converting to an integer... I do not think I will be the last person to make this mistake in a test. |
| Comments |
| Comment by Yujin Kang Park [ 07/Jul/23 ] |
|
Sending back to backlog. The change is more involved than initially thought, and we are unsure if it really is desired. IIRC, geert.bosch@mongodb.com had some concerns about potentially making the code more convoluted, and the change potentially being unsafe. Note that this change would also require updating the IDL parser to generate code using the scoped enums. |
| Comment by Blake Oler [ 22/Aug/22 ] |
|
Passing this along to Storage Execution, who owns the BSON library. (Confirmed by pavithra.vetriselvan@mongodb.com) |
| Comment by Alex Neben [ 22/Aug/22 ] |
|
I strongly agree with this change request however, I believe this is a service-arch ticket. |