Skip to content

Commit 16df6f0

Browse files
authored
Merge pull request #179 from weiznich/fix/178
2 parents 702ae3f + dbdcbc2 commit 16df6f0

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/pooled_connection/bb8.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
//! # async fn run_test() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
3838
//! # use schema::users::dsl::*;
3939
//! # let config = get_config();
40-
//! let pool = Pool::builder().build(config).await?;
40+
//! # #[cfg(feature = "postgres")]
41+
//! let pool: Pool<AsyncPgConnection> = Pool::builder().build(config).await?;
42+
//! # #[cfg(not(feature = "postgres"))]
43+
//! # let pool = Pool::builder().build(config).await?;
4144
//! let mut conn = pool.get().await?;
4245
//! # conn.begin_test_transaction();
4346
//! # create_tables(&mut conn).await;
@@ -53,6 +56,9 @@ use bb8::ManageConnection;
5356
use diesel::query_builder::QueryFragment;
5457

5558
/// Type alias for using [`bb8::Pool`] with [`diesel-async`]
59+
///
60+
/// This is **not** equal to [`bb8::Pool`]. It already uses the correct
61+
/// connection manager and expects only the connection type as generic argument
5662
pub type Pool<C> = bb8::Pool<AsyncDieselConnectionManager<C>>;
5763
/// Type alias for using [`bb8::PooledConnection`] with [`diesel-async`]
5864
pub type PooledConnection<'a, C> = bb8::PooledConnection<'a, AsyncDieselConnectionManager<C>>;

src/pooled_connection/deadpool.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
//! # async fn run_test() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
3838
//! # use schema::users::dsl::*;
3939
//! # let config = get_config();
40-
//! let pool = Pool::builder(config).build()?;
40+
//! # #[cfg(feature = "postgres")]
41+
//! let pool: Pool<AsyncPgConnection> = Pool::builder(config).build()?;
42+
//! # #[cfg(not(feature = "postgres"))]
43+
//! # let pool = Pool::builder(config).build()?;
4144
//! let mut conn = pool.get().await?;
4245
//! # conn.begin_test_transaction();
4346
//! # create_tables(&mut conn).await;
@@ -51,6 +54,9 @@ use deadpool::managed::Manager;
5154
use diesel::query_builder::QueryFragment;
5255

5356
/// Type alias for using [`deadpool::managed::Pool`] with [`diesel-async`]
57+
///
58+
/// This is **not** equal to [`deadpool::managed::Pool`]. It already uses the correct
59+
/// connection manager and expects only the connection type as generic argument
5460
pub type Pool<C> = deadpool::managed::Pool<AsyncDieselConnectionManager<C>>;
5561
/// Type alias for using [`deadpool::managed::PoolBuilder`] with [`diesel-async`]
5662
pub type PoolBuilder<C> = deadpool::managed::PoolBuilder<AsyncDieselConnectionManager<C>>;

src/pooled_connection/mobc.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
//! # async fn run_test() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
3838
//! # use schema::users::dsl::*;
3939
//! # let config = get_config();
40-
//! let pool = Pool::new(config);
40+
//! # #[cfg(feature = "postgres")]
41+
//! let pool: Pool<AsyncPgConnection> = Pool::new(config);
42+
//! # #[cfg(not(feature = "postgres"))]
43+
//! # let pool = Pool::new(config);
4144
//! let mut conn = pool.get().await?;
4245
//! # conn.begin_test_transaction();
4346
//! # create_tables(&mut conn).await;
@@ -51,6 +54,10 @@ use diesel::query_builder::QueryFragment;
5154
use mobc::Manager;
5255

5356
/// Type alias for using [`mobc::Pool`] with [`diesel-async`]
57+
///
58+
///
59+
/// This is **not** equal to [`mobc::Pool`]. It already uses the correct
60+
/// connection manager and expects only the connection type as generic argument
5461
pub type Pool<C> = mobc::Pool<AsyncDieselConnectionManager<C>>;
5562

5663
/// Type alias for using [`mobc::Connection`] with [`diesel-async`]

0 commit comments

Comments
 (0)