Skip to content

Commit

Permalink
Make the database kind queryable from AnyConnectionKind and AnyConnec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
05storm26 committed Dec 22, 2021
1 parent f0d0f2f commit 02ab060
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion sqlx-core/src/any/connection/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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(conn) => AnyKind::Postgres,

#[cfg(feature = "mysql")]
AnyConnectionKind::MySql(conn) => AnyKind::MySql,

#[cfg(feature = "sqlite")]
AnyConnectionKind::Sqlite(conn) => AnyKind::Sqlite,

#[cfg(feature = "mssql")]
AnyConnectionKind::Mssql(conn) => 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 {
Expand Down

0 comments on commit 02ab060

Please sign in to comment.