diff --git a/sqlx-core/src/any/connection/mod.rs b/sqlx-core/src/any/connection/mod.rs index 6ed4bfbd..d4b28bd4 100644 --- a/sqlx-core/src/any/connection/mod.rs +++ b/sqlx-core/src/any/connection/mod.rs @@ -1,6 +1,6 @@ use futures_core::future::BoxFuture; -use crate::any::{Any, AnyConnectOptions}; +use crate::any::{Any, AnyConnectOptions, AnyKind}; use crate::connection::Connection; use crate::error::Error; @@ -47,6 +47,30 @@ pub(crate) enum AnyConnectionKind { Sqlite(sqlite::SqliteConnection), } +impl AnyConnectionKind { + pub fn kind(&self) -> AnyKind { + match self { + #[cfg(feature = "postgres")] + AnyConnectionKind::Postgres(_) => AnyKind::Postgres, + + #[cfg(feature = "mysql")] + AnyConnectionKind::MySql(_) => AnyKind::MySql, + + #[cfg(feature = "sqlite")] + AnyConnectionKind::Sqlite(_) => AnyKind::Sqlite, + + #[cfg(feature = "mssql")] + AnyConnectionKind::Mssql(_) => AnyKind::Mssql, + } + } +} + +impl AnyConnection { + pub fn kind(&self) -> AnyKind { + self.0.kind() + } +} + macro_rules! delegate_to { ($self:ident.$method:ident($($arg:ident),*)) => { match &$self.0 {