-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ObjectId
error
#1224
Comments
Updating to use let users = database.collection::<DatabaseUser>(USER_COLLECTION);
let doc_users = database.collection::<bson::Document>(USER_COLLECTION);
info!("user_id:\n\t{user_id}\n\t{user_id:?}");
let find_doc = doc! { "_id": user_id };
info!("find_doc: {find_doc:?}");
let all_users = users.find(doc!{}).await.unwrap().collect::<Vec<Result<DatabaseUser,_>>>().await;
info!("all_users: {all_users:?}");
let all_users = doc_users.find(doc!{}).await.unwrap().collect::<Vec<Result<bson::Document,_>>>().await;
info!("all_users: {all_users:?}"); outputs
which suggests the problem is in https://github.com/mongodb/bson-rust since #[derive(Debug, Serialize, Deserialize)]
pub struct DatabaseUser {
pub _id: ObjectId,
pub pictures: BTreeMap<ObjectId, Glicko2Rating>,
// ...
} diving a little further there is a {
"_id": {
"$oid": "6709a1840466a4d817174c6c"
},
"email": "a",
"hash": "$argon2id$v=19$m=19456,t=2,p=1$pY0WSJ4qyxKwQuE7PM84VA$pAUXkdPaBRuzFZizeYZTBc7lVvjsMz8Hf9TChm8MYPM",
"pictures": {
"ObjectId(\"6709a1850466a4d817174c6d\")": {
"rating": 1500,
"deviation": 350,
"volatility": 0.06
},
"ObjectId(\"6709a1850466a4d817174c6e\")": {
"rating": 1500,
"deviation": 350,
"volatility": 0.06
},
"ObjectId(\"6709a1850466a4d817174c6f\")": {
"rating": 1500,
"deviation": 350,
"volatility": 0.06
},
"ObjectId(\"6709a1850466a4d817174c70\")": {
"rating": 1500,
"deviation": 350,
"volatility": 0.06
}
...
} |
An example JonathanWoollett-Light/testing@c965159 which can be run simply with Okay I think the point is in essence that using |
Versions/Environment
rustc 1.81.0 (eeb90cda1 2024-09-04)
Windows
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()
):mongodb-win32-x86_64-windows-7.0.14/bin/mongod.exe
Standalone
Describe the bug
Within my application I have
upon reaching and executing this in a test I get the error:
The notable section here being that it reports the
ObjectId
as670996bba2c4b6ec183babff
rather than670996baa2c4b6ec183babfe
.The logs are:
Checking the database with Mongdb Compass I can see:
The text was updated successfully, but these errors were encountered: