File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -275,18 +275,19 @@ pub(crate) async fn set_transaction_config(
275275 isolation_level : Option < IsolationLevel > ,
276276 access_mode : Option < AccessMode > ,
277277) -> Result < ( ) , DbErr > {
278+ let mut settings = Vec :: new ( ) ;
279+
278280 if let Some ( isolation_level) = isolation_level {
279- let stmt = Statement {
280- sql : format ! ( "SET TRANSACTION ISOLATION LEVEL {isolation_level}" ) ,
281- values : None ,
282- db_backend : DbBackend :: MySql ,
283- } ;
284- let query = sqlx_query ( & stmt) ;
285- conn. execute ( query) . await . map_err ( sqlx_error_to_exec_err) ?;
281+ settings. push ( format ! ( "ISOLATION LEVEL {isolation_level}" ) ) ;
286282 }
283+
287284 if let Some ( access_mode) = access_mode {
285+ settings. push ( access_mode. to_string ( ) ) ;
286+ }
287+
288+ if !settings. is_empty ( ) {
288289 let stmt = Statement {
289- sql : format ! ( "SET TRANSACTION {access_mode}" ) ,
290+ sql : format ! ( "SET TRANSACTION {}" , settings . join ( ", " ) ) ,
290291 values : None ,
291292 db_backend : DbBackend :: MySql ,
292293 } ;
You can’t perform that action at this time.
0 commit comments