From ab6ffba843cea2667420a1634d4c40987c66d916 Mon Sep 17 00:00:00 2001 From: Fankai Liu Date: Wed, 25 Oct 2023 21:48:39 +0800 Subject: [PATCH] add rbatis selecte --- src/utils/get_selection.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/utils/get_selection.rs b/src/utils/get_selection.rs index ccc2bb3..fc434b2 100644 --- a/src/utils/get_selection.rs +++ b/src/utils/get_selection.rs @@ -36,7 +36,7 @@ pub fn get_user_selected() -> Result> { t!("db_conn_types_sqlx"), t!("db_conn_types_sea_orm"), t!("db_conn_types_diesel"), - // t!("db_conn_types_rbatis"), + t!("db_conn_types_rbatis"), t!("db_conn_types_nothing"), // "custom", ]; @@ -50,8 +50,8 @@ pub fn get_user_selected() -> Result> { 0 => DbConnectionType::Sqlx, 1 => DbConnectionType::SeaOrm, 2 => DbConnectionType::Diesel, - 3 => DbConnectionType::Nothing, - // 3 => DbConnectionType::Rbatis, + 3 => DbConnectionType::Rbatis, + 4 => DbConnectionType::Nothing, _ => anyhow::bail!("Invalid db connection type selection"), }; if db_conn_type == DbConnectionType::Nothing { @@ -61,10 +61,14 @@ pub fn get_user_selected() -> Result> { db_conn_type, })); } - let db_types = &[ + let mut db_types: Vec<&str> = vec![ "sqlite", "mysql", "postgres", - // "custom", ]; + if db_conn_type == DbConnectionType::Rbatis { + db_types = vec![ + "sqlite", "mysql", "postgres", "mssql", + ]; + } let db_type_selection = Select::with_theme(&theme) .with_prompt(t!("select_db_type").replace(r"\n", "\n")) .default(0) @@ -74,6 +78,7 @@ pub fn get_user_selected() -> Result> { 0 => DbType::Sqlite, 1 => DbType::Mysql, 2 => DbType::Postgres, + 3 => DbType::Mssql, _ => anyhow::bail!("Invalid db type selection"), }; @@ -94,6 +99,7 @@ pub enum DbType { Sqlite, Mysql, Postgres, + Mssql, } #[derive(Debug, PartialEq, Clone)] @@ -101,6 +107,6 @@ pub enum DbConnectionType { Sqlx, SeaOrm, Diesel, - // Rbatis, + Rbatis, Nothing, }