mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-03 07:45:30 +00:00
Add executor trait "aliases" (#1412)
This commit is contained in:
parent
89ee690550
commit
335eed4545
@ -1,5 +1,7 @@
|
||||
//! Generic database driver with the specific driver selected at runtime.
|
||||
|
||||
use crate::executor::Executor;
|
||||
|
||||
#[macro_use]
|
||||
mod decode;
|
||||
|
||||
@ -45,6 +47,10 @@ pub type AnyPool = crate::pool::Pool<Any>;
|
||||
|
||||
pub type AnyPoolOptions = crate::pool::PoolOptions<Any>;
|
||||
|
||||
/// An alias for [`Executor<'_, Database = Any>`][Executor].
|
||||
pub trait AnyExecutor<'c>: Executor<'c, Database = Any> {}
|
||||
impl<'c, T: Executor<'c, Database = Any>> AnyExecutor<'c> for T {}
|
||||
|
||||
// NOTE: required due to the lack of lazy normalization
|
||||
impl_into_arguments_for_arguments!(AnyArguments<'q>);
|
||||
impl_executor_for_pool_connection!(Any, AnyConnection, AnyRow);
|
||||
|
@ -1,5 +1,7 @@
|
||||
//! Microsoft SQL (MSSQL) database driver.
|
||||
|
||||
use crate::executor::Executor;
|
||||
|
||||
mod arguments;
|
||||
mod column;
|
||||
mod connection;
|
||||
@ -32,6 +34,10 @@ pub use value::{MssqlValue, MssqlValueRef};
|
||||
/// An alias for [`Pool`][crate::pool::Pool], specialized for MSSQL.
|
||||
pub type MssqlPool = crate::pool::Pool<Mssql>;
|
||||
|
||||
/// An alias for [`Executor<'_, Database = Mssql>`][Executor].
|
||||
pub trait MssqlExecutor<'c>: Executor<'c, Database = Mssql> {}
|
||||
impl<'c, T: Executor<'c, Database = Mssql>> MssqlExecutor<'c> for T {}
|
||||
|
||||
// NOTE: required due to the lack of lazy normalization
|
||||
impl_into_arguments_for_arguments!(MssqlArguments);
|
||||
impl_executor_for_pool_connection!(Mssql, MssqlConnection, MssqlRow);
|
||||
|
@ -1,5 +1,7 @@
|
||||
//! **MySQL** database driver.
|
||||
|
||||
use crate::executor::Executor;
|
||||
|
||||
mod arguments;
|
||||
mod collation;
|
||||
mod column;
|
||||
@ -39,6 +41,10 @@ pub type MySqlPool = crate::pool::Pool<MySql>;
|
||||
/// An alias for [`PoolOptions`][crate::pool::PoolOptions], specialized for MySQL.
|
||||
pub type MySqlPoolOptions = crate::pool::PoolOptions<MySql>;
|
||||
|
||||
/// An alias for [`Executor<'_, Database = MySql>`][Executor].
|
||||
pub trait MySqlExecutor<'c>: Executor<'c, Database = MySql> {}
|
||||
impl<'c, T: Executor<'c, Database = MySql>> MySqlExecutor<'c> for T {}
|
||||
|
||||
// NOTE: required due to the lack of lazy normalization
|
||||
impl_into_arguments_for_arguments!(MySqlArguments);
|
||||
impl_executor_for_pool_connection!(MySql, MySqlConnection, MySqlRow);
|
||||
|
@ -1,5 +1,7 @@
|
||||
//! **PostgreSQL** database driver.
|
||||
|
||||
use crate::executor::Executor;
|
||||
|
||||
mod arguments;
|
||||
mod column;
|
||||
mod connection;
|
||||
@ -41,6 +43,10 @@ pub type PgPool = crate::pool::Pool<Postgres>;
|
||||
/// An alias for [`PoolOptions`][crate::pool::PoolOptions], specialized for Postgres.
|
||||
pub type PgPoolOptions = crate::pool::PoolOptions<Postgres>;
|
||||
|
||||
/// An alias for [`Executor<'_, Database = Postgres>`][Executor].
|
||||
pub trait PgExecutor<'c>: Executor<'c, Database = Postgres> {}
|
||||
impl<'c, T: Executor<'c, Database = Postgres>> PgExecutor<'c> for T {}
|
||||
|
||||
impl_into_arguments_for_arguments!(PgArguments);
|
||||
impl_executor_for_pool_connection!(Postgres, PgConnection, PgRow);
|
||||
impl_executor_for_transaction!(Postgres, PgRow);
|
||||
|
@ -5,6 +5,8 @@
|
||||
// invariants.
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use crate::executor::Executor;
|
||||
|
||||
mod arguments;
|
||||
mod column;
|
||||
mod connection;
|
||||
@ -43,6 +45,10 @@ pub type SqlitePool = crate::pool::Pool<Sqlite>;
|
||||
/// An alias for [`PoolOptions`][crate::pool::PoolOptions], specialized for SQLite.
|
||||
pub type SqlitePoolOptions = crate::pool::PoolOptions<Sqlite>;
|
||||
|
||||
/// An alias for [`Executor<'_, Database = Sqlite>`][Executor].
|
||||
pub trait SqliteExecutor<'c>: Executor<'c, Database = Sqlite> {}
|
||||
impl<'c, T: Executor<'c, Database = Sqlite>> SqliteExecutor<'c> for T {}
|
||||
|
||||
// NOTE: required due to the lack of lazy normalization
|
||||
impl_into_arguments_for_arguments!(SqliteArguments<'q>);
|
||||
impl_executor_for_pool_connection!(Sqlite, SqliteConnection, SqliteRow);
|
||||
|
10
src/lib.rs
10
src/lib.rs
@ -46,23 +46,23 @@ pub use sqlx_core::migrate;
|
||||
),
|
||||
feature = "any"
|
||||
))]
|
||||
pub use sqlx_core::any::{self, Any, AnyConnection, AnyPool};
|
||||
pub use sqlx_core::any::{self, Any, AnyConnection, AnyExecutor, AnyPool};
|
||||
|
||||
#[cfg(feature = "mysql")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))]
|
||||
pub use sqlx_core::mysql::{self, MySql, MySqlConnection, MySqlPool};
|
||||
pub use sqlx_core::mysql::{self, MySql, MySqlConnection, MySqlExecutor, MySqlPool};
|
||||
|
||||
#[cfg(feature = "mssql")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "mssql")))]
|
||||
pub use sqlx_core::mssql::{self, Mssql, MssqlConnection, MssqlPool};
|
||||
pub use sqlx_core::mssql::{self, Mssql, MssqlConnection, MssqlExecutor, MssqlPool};
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))]
|
||||
pub use sqlx_core::postgres::{self, PgConnection, PgPool, Postgres};
|
||||
pub use sqlx_core::postgres::{self, PgConnection, PgExecutor, PgPool, Postgres};
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "sqlite")))]
|
||||
pub use sqlx_core::sqlite::{self, Sqlite, SqliteConnection, SqlitePool};
|
||||
pub use sqlx_core::sqlite::{self, Sqlite, SqliteConnection, SqliteExecutor, SqlitePool};
|
||||
|
||||
#[cfg(feature = "macros")]
|
||||
#[doc(hidden)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user