From f12788dbf9edc1f924b24176038e38280e886108 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 4 May 2022 12:38:29 -0700 Subject: [PATCH] Synchronize 'db_pools' docs with libraries. Also adds an integration test designed to break if upstream types change in a manner incompatible with docs. --- contrib/db_pools/lib/src/lib.rs | 10 ++-- contrib/db_pools/lib/tests/databases.rs | 67 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 contrib/db_pools/lib/tests/databases.rs diff --git a/contrib/db_pools/lib/src/lib.rs b/contrib/db_pools/lib/src/lib.rs index fb4fc0ec..88947aae 100644 --- a/contrib/db_pools/lib/src/lib.rs +++ b/contrib/db_pools/lib/src/lib.rs @@ -106,16 +106,16 @@ //! | Database | Feature | [`Pool`] Type | [`Connection`] Deref | //! |----------|---------------------|-----------------------------|---------------------------------------| //! | 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) //! //! | Database | Feature | [`Pool`] Type | [`Connection`] Deref | //! |----------|-----------------|----------------------|------------------------------------| -//! | Postgres | `sqlx_postgres` | [`sqlx::PgPool`] | [`sqlx::PoolConnection`] | -//! | MySQL | `sqlx_mysql` | [`sqlx::MySqlPool`] | [`sqlx::PoolConnection`] | -//! | SQLite | `sqlx_sqlite` | [`sqlx::SqlitePool`] | [`sqlx::PoolConnection`] | -//! | MSSQL | `sqlx_mssql` | [`sqlx::MssqlPool`] | [`sqlx::PoolConnection`] | +//! | Postgres | `sqlx_postgres` | [`sqlx::PgPool`] | [`sqlx::pool::PoolConnection`] | +//! | MySQL | `sqlx_mysql` | [`sqlx::MySqlPool`] | [`sqlx::pool::PoolConnection`] | +//! | SQLite | `sqlx_sqlite` | [`sqlx::SqlitePool`] | [`sqlx::pool::PoolConnection`] | +//! | MSSQL | `sqlx_mssql` | [`sqlx::MssqlPool`] | [`sqlx::pool::PoolConnection`] | //! //! [`sqlx::PgPool`]: https://docs.rs/sqlx/0.5/sqlx/type.PgPool.html //! [`sqlx::MySqlPool`]: https://docs.rs/sqlx/0.5/sqlx/type.MySqlPool.html diff --git a/contrib/db_pools/lib/tests/databases.rs b/contrib/db_pools/lib/tests/databases.rs new file mode 100644 index 00000000..ce0bd369 --- /dev/null +++ b/contrib/db_pools/lib/tests/databases.rs @@ -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) { + 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, +); + +check_types_match!( + "sqlx_mysql", + sqlx_mysql, + sqlx::MySqlPool, + sqlx::pool::PoolConnection, +); + +check_types_match!( + "sqlx_sqlite", + sqlx_sqlite, + sqlx::SqlitePool, + sqlx::pool::PoolConnection, +); + +check_types_match!( + "sqlx_mssql", + sqlx_mssql, + sqlx::MssqlPool, + sqlx::pool::PoolConnection, +); + +check_types_match!( + "mongodb", + mongodb, + mongodb::Client, + mongodb::Client, +);