Skip to content

Update for 2.6.1 release #933

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

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ homepage = "https://www.mongodb.com/docs/drivers/rust/"
license = "Apache-2.0"
readme = "README.md"
name = "mongodb"
version = "2.6.0"
version = "2.6.1"

exclude = [
"etc/**",
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The driver tests against Linux, MacOS, and Windows in CI.
The driver is available on [crates.io](https://crates.io/crates/mongodb). To use the driver in your application, simply add it to your project's `Cargo.toml`.
```toml
[dependencies]
mongodb = "2.6.0"
mongodb = "2.6.1"
```

Version 1 of this crate has reached end of life and will no longer be receiving any updates or bug fixes, so all users are recommended to always depend on the latest 2.x release. See the [2.0.0 release notes](https://github.com/mongodb/mongo-rust-driver/releases/tag/v2.0.0) for migration information if upgrading from a 1.x version.
Expand All @@ -55,7 +55,7 @@ The driver supports both of the most popular async runtime crates, namely [`toki
For example, to instruct the driver to work with [`async-std`](https://crates.io/crates/async-std), add the following to your `Cargo.toml`:
```toml
[dependencies.mongodb]
version = "2.6.0"
version = "2.6.1"
default-features = false
features = ["async-std-runtime"]
```
Expand All @@ -64,7 +64,7 @@ features = ["async-std-runtime"]
The driver also provides a blocking sync API. To enable this, add the `"sync"` or `"tokio-sync"` feature to your `Cargo.toml`:
```toml
[dependencies.mongodb]
version = "2.6.0"
version = "2.6.1"
features = ["tokio-sync"]
```
Using the `"sync"` feature also requires using `default-features = false`.
Expand Down
4 changes: 2 additions & 2 deletions manual/src/installation_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The driver supports both of the most popular async runtime crates, namely [`toki
For example, to instruct the driver to work with [`async-std`](https://crates.io/crates/async-std), add the following to your `Cargo.toml`:
```toml
[dependencies.mongodb]
version = "2.6.0"
version = "2.6.1"
default-features = false
features = ["async-std-runtime"]
```
Expand All @@ -22,7 +22,7 @@ features = ["async-std-runtime"]
The driver also provides a blocking sync API. To enable this, add the `"sync"` or `"tokio-sync"` feature to your `Cargo.toml`:
```toml
[dependencies.mongodb]
version = "2.6.0"
version = "2.6.1"
features = ["tokio-sync"]
```
Using the `"sync"` feature also requires using `default-features = false`.
Expand Down
12 changes: 3 additions & 9 deletions src/coll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use serde::{

use self::options::*;
use crate::{
bson::{doc, to_document_with_options, Bson, Document, SerializerOptions},
bson::{doc, to_document, Bson, Document},
bson_util,
change_stream::{
event::ChangeStreamEvent,
Expand Down Expand Up @@ -1119,10 +1119,7 @@ where
options: impl Into<Option<FindOneAndReplaceOptions>>,
session: impl Into<Option<&mut ClientSession>>,
) -> Result<Option<T>> {
let replacement = to_document_with_options(
replacement.borrow(),
SerializerOptions::builder().human_readable(false).build(),
)?;
let replacement = to_document(replacement.borrow())?;

let session = session.into();

Expand Down Expand Up @@ -1382,10 +1379,7 @@ where
options: impl Into<Option<ReplaceOptions>>,
session: impl Into<Option<&mut ClientSession>>,
) -> Result<UpdateResult> {
let replacement = to_document_with_options(
replacement.borrow(),
SerializerOptions::builder().human_readable(false).build(),
)?;
let replacement = to_document(replacement.borrow())?;

bson_util::replacement_document_check(&replacement)?;

Expand Down
12 changes: 3 additions & 9 deletions src/cursor/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,15 @@ impl<T> SessionCursor<T> {
where
D: Deserialize<'a>,
{
let out = SessionCursor {
SessionCursor {
client: self.client.clone(),
info: self.info.clone(),
state: Some(self.take_state()),
drop_address: self.drop_address.take(),
_phantom: Default::default(),
#[cfg(test)]
kill_watcher: self.kill_watcher.take(),
};
self.mark_exhausted(); // prevent a `kill_cursor` call in `drop`
out
}
}

pub(crate) fn address(&self) -> &ServerAddress {
Expand All @@ -346,12 +344,8 @@ impl<T> SessionCursor<T> {
}

impl<T> SessionCursor<T> {
fn mark_exhausted(&mut self) {
self.state.as_mut().unwrap().exhausted = true;
}

pub(crate) fn is_exhausted(&self) -> bool {
self.state.as_ref().unwrap().exhausted
self.state.as_ref().map_or(true, |state| state.exhausted)
}

#[cfg(test)]
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! your application, simply add it to your project's `Cargo.toml`.
//! ```toml
//! [dependencies]
//! mongodb = "2.6.0"
//! mongodb = "2.6.1"
//! ```
//!
//! ### Configuring the async runtime
Expand All @@ -30,7 +30,7 @@
//! add the following to your `Cargo.toml`:
//! ```toml
//! [dependencies.mongodb]
//! version = "2.6.0"
//! version = "2.6.1"
//! default-features = false
//! features = ["async-std-runtime"]
//! ```
Expand All @@ -40,7 +40,7 @@
//! feature to your `Cargo.toml`:
//! ```toml
//! [dependencies.mongodb]
//! version = "2.6.0"
//! version = "2.6.1"
//! features = ["tokio-sync"]
//! ```
//! Using the `"sync"` feature also requires using `default-features = false`.
Expand Down Expand Up @@ -303,7 +303,7 @@
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(test, type_length_limit = "80000000")]
#![doc(html_root_url = "https://docs.rs/mongodb/2.6.0")]
#![doc(html_root_url = "https://docs.rs/mongodb/2.6.1")]

#[cfg(all(feature = "aws-auth", feature = "async-std-runtime"))]
compile_error!("The `aws-auth` feature flag is only supported on the tokio runtime.");
Expand Down
30 changes: 30 additions & 0 deletions src/test/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,33 @@ async fn borrowed_deserialization() {
i += 1;
}
}

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn session_cursor_with_type() {
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
let client = TestClient::new().await;

let mut session = client.start_session(None).await.unwrap();
let coll = client.database("db").collection("coll");
coll.drop_with_session(None, &mut session).await.unwrap();

coll.insert_many_with_session(
vec![doc! { "x": 1 }, doc! { "x": 2 }, doc! { "x": 3 }],
None,
&mut session,
)
.await
.unwrap();

let mut cursor: crate::SessionCursor<bson::Document> = coll
.find_with_session(doc! {}, None, &mut session)
.await
.unwrap();

let _ = cursor.next(&mut session).await.unwrap().unwrap();

let mut cursor_with_type: crate::SessionCursor<bson::RawDocumentBuf> = cursor.with_type();

let _ = cursor_with_type.next(&mut session).await.unwrap().unwrap();
}