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 versions of the driver and its dependencies are you using? (Run cargo pkgid mongodb & cargo pkgid bson) registry+https://github.com/rust-lang/crates.io-index#[email protected] registry+https://github.com/rust-lang/crates.io-index#[email protected]
What version of MongoDB are you using? (Check with the MongoDB shell using db.version()) db version v7.0.7
What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)? 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:
let filter = doc! {"_id": { "$eq": id } }; // id is a Uuid
let res = collection.find_one(filter, None).await?;
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 use Binary::subtype::Uuid
Making my find always return None ....
To reproduce:
let options = SerializerOptions::builder().human_readable(false).build();
dbg!(bson::to_bson_with_options(&Uuid::new_v4(), options));
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#[email protected]
registry+https://github.com/rust-lang/crates.io-index#[email protected]
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:
The text was updated successfully, but these errors were encountered: