From 17232063b3dd9507d26528075a3d28b58f99cd35 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Mon, 8 Nov 2021 22:29:18 +0800 Subject: [PATCH] This will fail loll --- .github/workflows/rust.yml | 2 +- src/database/db_connection.rs | 16 ++++++++++++++++ src/driver/sqlx_mysql.rs | 2 +- tests/returning_tests.rs | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 35ef5cc1..c4d11235 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -517,7 +517,7 @@ jobs: strategy: fail-fast: false matrix: - version: [13.3, 12.7, 11.12, 10.17, 9.6.22] + version: [13, 12, 11, 10, 9] runtime: [tokio] tls: [native-tls] services: diff --git a/src/database/db_connection.rs b/src/database/db_connection.rs index 66385876..d428e11e 100644 --- a/src/database/db_connection.rs +++ b/src/database/db_connection.rs @@ -269,6 +269,22 @@ impl DatabaseConnection { } impl DatabaseConnection { + /// Get database version + pub fn version(&self) -> String { + match self { + #[cfg(feature = "sqlx-mysql")] + DatabaseConnection::SqlxMySqlPoolConnection { version, .. } => version.to_string(), + #[cfg(feature = "sqlx-postgres")] + DatabaseConnection::SqlxPostgresPoolConnection(_) => "".to_string(), + #[cfg(feature = "sqlx-sqlite")] + DatabaseConnection::SqlxSqlitePoolConnection(_) => "".to_string(), + #[cfg(feature = "mock")] + DatabaseConnection::MockDatabaseConnection(_) => "".to_string(), + DatabaseConnection::Disconnected => panic!("Disconnected"), + _ => unimplemented!(), + } + } + /// Check if database supports `RETURNING` pub fn support_returning(&self) -> bool { match self { diff --git a/src/driver/sqlx_mysql.rs b/src/driver/sqlx_mysql.rs index dae6b0d3..b66e1078 100644 --- a/src/driver/sqlx_mysql.rs +++ b/src/driver/sqlx_mysql.rs @@ -221,6 +221,6 @@ async fn into_db_connection(pool: MySqlPool) -> Result Result<(), DbErr> { } create_tables(db).await?; + println!("db_version: {:#?}", db.version()); db.query_one(builder.build(&insert)).await?; db.query_one(builder.build(&update)).await?; assert!(false);