Skip to content

Commit 02ab060

Browse files
committed
Make the database kind queryable from AnyConnectionKind and AnyConnection
1 parent f0d0f2f commit 02ab060

File tree

1 file changed

+25
-1
lines changed
  • sqlx-core/src/any/connection

1 file changed

+25
-1
lines changed

sqlx-core/src/any/connection/mod.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use futures_core::future::BoxFuture;
22

3-
use crate::any::{Any, AnyConnectOptions};
3+
use crate::any::{Any, AnyConnectOptions, AnyKind};
44
use crate::connection::Connection;
55
use crate::error::Error;
66

@@ -47,6 +47,30 @@ pub(crate) enum AnyConnectionKind {
4747
Sqlite(sqlite::SqliteConnection),
4848
}
4949

50+
impl AnyConnectionKind {
51+
pub fn kind(&self) -> AnyKind {
52+
match self {
53+
#[cfg(feature = "postgres")]
54+
AnyConnectionKind::Postgres(conn) => AnyKind::Postgres,
55+
56+
#[cfg(feature = "mysql")]
57+
AnyConnectionKind::MySql(conn) => AnyKind::MySql,
58+
59+
#[cfg(feature = "sqlite")]
60+
AnyConnectionKind::Sqlite(conn) => AnyKind::Sqlite,
61+
62+
#[cfg(feature = "mssql")]
63+
AnyConnectionKind::Mssql(conn) => AnyKind::Mssql,
64+
}
65+
}
66+
}
67+
68+
impl AnyConnection {
69+
pub fn kind(&self) -> AnyKind {
70+
self.0.kind()
71+
}
72+
}
73+
5074
macro_rules! delegate_to {
5175
($self:ident.$method:ident($($arg:ident),*)) => {
5276
match &$self.0 {

0 commit comments

Comments
 (0)