Skip to content

Commit 6525f4f

Browse files
wip
1 parent d9b7ea3 commit 6525f4f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/modules/db/sqlx/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use quickjs_runtime::reflection::get_proxy_instance_id;
1717
use quickjs_runtime::values::{JsValueFacade, TypedArrayType};
1818
use sqlx_lib::mysql::MySqlPoolOptions;
1919
use sqlx_lib::postgres::PgPoolOptions;
20+
use sqlx_lib::Executor;
2021
use sqlx_lib::{
2122
Column, MySql, MySqlExecutor, PgExecutor, Pool, Postgres, Row, Transaction, TypeInfo,
2223
};
@@ -695,6 +696,13 @@ impl SqlxConnection {
695696
let con = match protocol_type {
696697
"mysql" => {
697698
let mysql_pool = MySqlPoolOptions::new()
699+
.after_connect(|conn, _pool_connection_metadata| {
700+
Box::pin(async move {
701+
conn.execute("SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED")
702+
.await?;
703+
Ok(())
704+
})
705+
})
698706
.acquire_timeout(Duration::from_secs(15))
699707
.idle_timeout(Duration::from_secs(60))
700708
.max_lifetime(Duration::from_secs(3600))
@@ -709,6 +717,13 @@ impl SqlxConnection {
709717
}
710718
"postgres" => {
711719
let pg_pool = PgPoolOptions::new()
720+
.after_connect(|conn, _pool_connection_metadata| {
721+
Box::pin(async move {
722+
conn.execute("SET default_transaction_isolation TO 'read committed'")
723+
.await?;
724+
Ok(())
725+
})
726+
})
712727
.acquire_timeout(Duration::from_secs(15))
713728
.idle_timeout(Duration::from_secs(60))
714729
.max_lifetime(Duration::from_secs(3600))

0 commit comments

Comments
 (0)