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
use mongodb::bson::{doc,Document};use mongodb::bson::oid::ObjectId;use mongodb::{ClientSession,Collection,SessionCursor,Client};use serde::{Serialize,Deserialize};#[derive(Serialize,Deserialize)]structRecord{#[serde(rename = "_id")]id:ObjectId,foobar:i32,}asyncfnmain(){let client = Client::with_uri_str("i_dont_care").await.unwrap();let collection:Collection<Record> = client.database("db").collection("collection");let id = ObjectId::default();let pipeline = vec![doc!{"_id": id }];let aggregation = collection.aggregate(pipeline);let typed_aggregation = aggregation.with_type::<Record>();// Correct type // let records: Cursor<Record> = typed_aggregation.await.unwrap();letmut session = client.start_session().await.unwrap();// We lose type from original aggregation and get SessionCursor<Document>// Shoudn't this be SessionCursor<Record> based on the previous type of PhantomData<Record> in Aggregation??let with_session:SessionCursor<Document> = typed_aggregation.session(session).await?;}
The text was updated successfully, but these errors were encountered:
Thanks for the report! This looks like a simple oversight on our part - I'll get a bugfix for this out shortly. In the meantime, you can work around this by calling with_type after session rather than before.
abr-egn
changed the title
Aggregation is losing type after session
RUST-2191 Aggregation is losing type after session
Mar 31, 2025
Aggregation is losing type after session.
Here is an example of what I mean by losing type.
The text was updated successfully, but these errors were encountered: