@@ -4,14 +4,14 @@ use tokio_postgres::{connect, NoTls};
44use crate :: { utils:: reflective_get, AppState } ;
55
66#[ tauri:: command( rename_all = "snake_case" ) ]
7- pub async fn postgresql_connector ( project : & str , key : & str , app : AppHandle ) -> Result < Vec < String > > {
7+ pub async fn postgresql_connector (
8+ project_name : & str ,
9+ key : & str ,
10+ app : AppHandle ,
11+ ) -> Result < Vec < String > > {
812 let app_state = app. state :: < AppState > ( ) ;
9- let mut db = app_state. project_db . lock ( ) . await ;
10- if let Some ( ref mut db_instance) = * db {
11- db_instance. insert ( project, key) . unwrap ( ) ;
12- }
13-
1413 let ( client, connection) = connect ( key, NoTls ) . await . expect ( "connection error" ) ;
14+
1515 tokio:: spawn ( async move {
1616 if let Err ( e) = connection. await {
1717 eprintln ! ( "connection error: {}" , e) ;
@@ -32,7 +32,7 @@ pub async fn postgresql_connector(project: &str, key: &str, app: AppHandle) -> R
3232 let schemas = schemas. iter ( ) . map ( |r| r. get ( 0 ) ) . collect ( ) ;
3333 let mut clients = app_state. client . lock ( ) . await ;
3434 let clients = clients. as_mut ( ) . unwrap ( ) ;
35- clients. insert ( project . to_string ( ) , client) ;
35+ clients. insert ( project_name . to_string ( ) , client) ;
3636
3737 Ok ( schemas)
3838}
@@ -66,6 +66,7 @@ pub async fn select_schema_tables(
6666 . iter ( )
6767 . map ( |r| ( r. get ( 0 ) , r. get ( 1 ) ) )
6868 . collect :: < Vec < ( String , String ) > > ( ) ;
69+
6970 Ok ( tables)
7071}
7172
0 commit comments