Open
Description
Describe the bug
See reproduction below:
let test_doc = doc! {
"acutalTimestamp": bson::Timestamp {increment: 0, time: 12345},
"operationTime": {"$timestamp": "7248047827882870681"},
};
let mut bson_bytes = Vec::<u8>::new();
bson::Document::to_writer(&test_doc, &mut bson_bytes)?;
let deserialized = bson::from_slice::<bson::Document>(&bson_bytes)?;
This errors with:
Error: invalid type: string "7248047827882870681", expected struct TimestampBody
test_doc
is a valid BSON document, however the deserializer doesn't make any distinction between a $timestamp
from an actual Timestamp vs. just a document with a $timestamp
key. This causes issues with custom Deserialize
implementations for data structures, where I can't figure out how to differentiate between a real Timestamp
and a Document
.
BE SPECIFIC:
- What is the expected behavior and what is actually happening?
- This should not error, but it does.