Closed AzHicham closed 7 months ago
Hi!
Given that you're constructing your UUID with new_v4
, I'm guessing that you're using the uuid
crate directly. Unfortunately, the Serialize
implementation for uuid::Uuid
doesn't produce valid BSON UUIDs, for that you'll need to use bson::Uuid
.
There has not been any recent activity on this ticket, so we are marking it as stale. If we do not hear anything further from you, this issue will be automatically closed in one week.
There has not been any recent activity on this ticket, so we are closing it. Thanks for reaching out and please feel free to file a new issue if you have further questions.
Versions/Environment
1.77.0
Ubuntu 23.04
cargo pkgid mongodb
&cargo pkgid bson
)registry+https://github.com/rust-lang/crates.io-index#mongodb@2.8.2
registry+https://github.com/rust-lang/crates.io-index#bson@2.9.0
db.version()
)db version v7.0.7
standalone
Describe the bug
I have a simple collection of this struct
Analysis { _id: Uuid, value: f32 }
I insert analysis in my collection with this:let res = collection.insert_one(&Analysis { _id: Uuid::new_v4(), value: 0_f32 }, None).await?; dbg!(res)
Then I try to find this analysis in my collection this way:
But without success...
I find out that the serialization involved during inserting will insert uuids as
Binary::subtype::Generic
but the serialization involved during the find will useBinary::subtype::Uuid
Making my find always return None ....
To reproduce:
Output: