[CSHARP-2074] Improve how GuidRepresentation is handled Created: 30/Oct/17  Updated: 10/Jan/20  Resolved: 10/Jan/20

Status: Closed
Project: C# Driver
Component/s: BSON
Affects Version/s: 2.11.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-2724 Implement specification for handling ... Closed
Related
is related to CSHARP-2218 BsonBinaryData constructor throws inc... Closed

 Description   

Early on the decision was made that all Guids in a collection MUST be represented the same way. The rationale was that mixing Guid representations in the same collection would lead to confusion.

This was enforced by the readers/writers and serializers which looked at the GuidRepresentation value of the reader/writer settings (which came from the collection settings). The readers/writers/serializers either do automatic conversions or throw exceptions as necessary to enforce the constraint that all Guids in a collection MUST be represented the same way.

This constraint, and the automatic conversions in particular, have become problematic now that the server has started using UUIDs (e.g. ListCollections results and session Ids among others).

The server only uses BSON binary subtype 4 for UUIDs, so any automatic conversions to subtype 3 result in server errors.

At the very least we need to support a mix of subtype 3 and 4 in the same document.

In the longer term we should probably remove all conversions/checks from the readers/writers and leave all decisions about Guid representation up to the serializers.

Changing how we handle Guid serialization could have subtle backward compatibility issues.



 Comments   
Comment by Robert Stam [ 10/Jan/20 ]

This work is now being done by the implementation of the new UUID spec in CSHARP-2724.

Generated at Wed Feb 07 21:41:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.