[GODRIVER-2702] bsoncore.Value#String() should persist timestamp types Created: 16/Dec/22  Updated: 28/Oct/23  Resolved: 20/Dec/22

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.11.2

Type: Bug Priority: Unknown
Reporter: Preston Vasquez Assignee: Preston Vasquez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

"bsoncore.Value#String()" is meant be extended JSON but stringifies the timestamp uint32 values for I and U which is antethesis of the expected behavior. This effects both bson.Raw#String() and bson.RawValue#String(). Decoding the stringified value of either will result in the following error:

var doc bson.Raw
if err := bson.UnmarshalExtJSON([]byte(cmdCopy.String()), true, &doc); err != nil {
        // panic: error: $timestamp t value should be uint32, but instead is string
	panic(fmt.Sprintf("error: %v", err)) 
}



 Comments   
Comment by Matt Dale [ 11/Feb/23 ]

Cherry-picked commit 4e038d8b969b3632a9b00c7f48b5e8bdc1d586ae into release/1.11.

Comment by Matt Dale [ 11/Feb/23 ]

Note that this is merged as commit 4e038d8b969b3632a9b00c7f48b5e8bdc1d586ae, which references GODRIVER-2570 instead of this ticket, so the automated Jira integration will not comment here.

Generated at Thu Feb 08 08:39:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.