You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version of MongoDB are you using? (Check with the MongoDB shell using db.version())
6.0
What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?
replica set
Describe the bug
For types that use different a serializer for human-readable serialization, we face the following issue:
When inserted, values are serialized by the non-human readable serializer on account of using bson::to_vec under the hood.
However, if we try to replace such values all replace methods in Collection use internally bson::to_document that uses the human-readable serializer.
This implies that if we attempt to find such a value that has been replaced and deserialize, we will either get a deserialization error, or incorrect data.
To Reproduce
Steps to reproduce the behavior:
Define a type that implements serde_with::SerializeAs using different serializers for human-readable (e.g. String) and non-readable (e.g. Bytes).
Then insert a value of this type into a collection. Store it as original
After doing that, replace that value with a clone of itself using any of the Collection methods that replace values (e.g. replace_one).
Get the replaced value replaced from the database and verify that !assert_eq!(original, replaced).
The text was updated successfully, but these errors were encountered:
Versions/Environment
cargo pkgid mongodb
&cargo pkgid bson
)db.version()
)Describe the bug
For types that use different a serializer for human-readable serialization, we face the following issue:
When inserted, values are serialized by the non-human readable serializer on account of using
bson::to_vec
under the hood.However, if we try to replace such values all
replace
methods in Collection use internallybson::to_document
that uses the human-readable serializer.This implies that if we attempt to find such a value that has been replaced and deserialize, we will either get a deserialization error, or incorrect data.
To Reproduce
Steps to reproduce the behavior:
serde_with::SerializeAs
using different serializers for human-readable (e.g.String
) and non-readable (e.g.Bytes
).original
replace_one
).replaced
from the database and verify that!assert_eq!(original, replaced)
.The text was updated successfully, but these errors were encountered: