Synchronize 'db_pools' docs with libraries.

Also adds an integration test designed to break if upstream types change
in a manner incompatible with docs.
This commit is contained in:
Sergio Benitez 2022-05-04 12:38:29 -07:00
parent 54224618b2
commit f12788dbf9
2 changed files with 72 additions and 5 deletions

View File

@ -106,16 +106,16 @@
//! | Database | Feature | [`Pool`] Type | [`Connection`] Deref | //! | Database | Feature | [`Pool`] Type | [`Connection`] Deref |
//! |----------|---------------------|-----------------------------|---------------------------------------| //! |----------|---------------------|-----------------------------|---------------------------------------|
//! | Postgres | `deadpool_postgres` | [`deadpool_postgres::Pool`] | [`deadpool_postgres::ClientWrapper`] | //! | Postgres | `deadpool_postgres` | [`deadpool_postgres::Pool`] | [`deadpool_postgres::ClientWrapper`] |
//! | Redis | `deadpool_redis` | [`deadpool_redis::Pool`] | [`deadpool_redis::ConnectionWrapper`] | //! | Redis | `deadpool_redis` | [`deadpool_redis::Pool`] | [`deadpool_redis::Connection`] |
//! //!
//! ## `sqlx` (v0.5) //! ## `sqlx` (v0.5)
//! //!
//! | Database | Feature | [`Pool`] Type | [`Connection`] Deref | //! | Database | Feature | [`Pool`] Type | [`Connection`] Deref |
//! |----------|-----------------|----------------------|------------------------------------| //! |----------|-----------------|----------------------|------------------------------------|
//! | Postgres | `sqlx_postgres` | [`sqlx::PgPool`] | [`sqlx::PoolConnection<Postgres>`] | //! | Postgres | `sqlx_postgres` | [`sqlx::PgPool`] | [`sqlx::pool::PoolConnection<Postgres>`] |
//! | MySQL | `sqlx_mysql` | [`sqlx::MySqlPool`] | [`sqlx::PoolConnection<MySql>`] | //! | MySQL | `sqlx_mysql` | [`sqlx::MySqlPool`] | [`sqlx::pool::PoolConnection<MySql>`] |
//! | SQLite | `sqlx_sqlite` | [`sqlx::SqlitePool`] | [`sqlx::PoolConnection<Sqlite>`] | //! | SQLite | `sqlx_sqlite` | [`sqlx::SqlitePool`] | [`sqlx::pool::PoolConnection<Sqlite>`] |
//! | MSSQL | `sqlx_mssql` | [`sqlx::MssqlPool`] | [`sqlx::PoolConnection<Mssql>`] | //! | MSSQL | `sqlx_mssql` | [`sqlx::MssqlPool`] | [`sqlx::pool::PoolConnection<Mssql>`] |
//! //!
//! [`sqlx::PgPool`]: https://docs.rs/sqlx/0.5/sqlx/type.PgPool.html //! [`sqlx::PgPool`]: https://docs.rs/sqlx/0.5/sqlx/type.PgPool.html
//! [`sqlx::MySqlPool`]: https://docs.rs/sqlx/0.5/sqlx/type.MySqlPool.html //! [`sqlx::MySqlPool`]: https://docs.rs/sqlx/0.5/sqlx/type.MySqlPool.html

View File

@ -0,0 +1,67 @@
macro_rules! check_types_match {
($feature:expr, $name:ident, $Pool:ty, $Conn:ty $(,)?) => (
#[cfg(feature = $feature)]
mod $name {
use rocket::*;
use rocket_db_pools::{Connection, Database};
#[derive(Database)]
#[database("foo")]
struct Db($Pool);
#[get("/")]
fn _db(conn: Connection<Db>) {
let _: &$Conn = &*conn;
}
}
)
}
check_types_match!(
"deadpool_postgres",
deadpool_postgres,
deadpool_postgres::Pool,
deadpool_postgres::ClientWrapper,
);
check_types_match!(
"deadpool_redis",
deadpool_redis,
deadpool_redis::Pool,
deadpool_redis::Connection,
);
check_types_match!(
"sqlx_postgres",
sqlx_postgres,
sqlx::PgPool,
sqlx::pool::PoolConnection<sqlx::Postgres>,
);
check_types_match!(
"sqlx_mysql",
sqlx_mysql,
sqlx::MySqlPool,
sqlx::pool::PoolConnection<sqlx::MySql>,
);
check_types_match!(
"sqlx_sqlite",
sqlx_sqlite,
sqlx::SqlitePool,
sqlx::pool::PoolConnection<sqlx::Sqlite>,
);
check_types_match!(
"sqlx_mssql",
sqlx_mssql,
sqlx::MssqlPool,
sqlx::pool::PoolConnection<sqlx::Mssql>,
);
check_types_match!(
"mongodb",
mongodb,
mongodb::Client,
mongodb::Client,
);