|
This ticket only applies to, I believe, the Python, Java, and .NET drivers.
When a document returned from the database includes values of type BSON Binary with subtype 4, drivers that support native UUID types decode those values to their native UUID type with no changes to the order of the bytes returned by the server, ignoring uuidRepresentation. If the application has set uuidRepresentation to "standard" the value will be encoded back to BSON Binary with subtype 4 and round trip properly. If the application has set uuidRepresentation to some other value (or used the default, which is driver specific) the encoder will encode the value to BSON binary subtype 3, and possibly change its byte order, when round tripped. The problem gets worse when the database returns values of both BSON binary subtype 3 and subtype 4 in a single document (this could be common with change streams which return a subtype 4 BSON Binary as part of the resumeToken value).
To solve this problem I propose we add a new uuidRepresentation, "binary". When uuidRepresentation is set to "binary" the driver decodes BSON Binary with subtype 3 or 4 to Binary with the given subtype instead of decoding to the driver's native UUID type. This setting can be used to reliably round trip UUIDs regardless of their original format.
|