-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
I want to use local/system timezone in MySqlPool.
let datetime = chrono::Utc::now().naive_local();
// The insert time is not equal to local time
sqlx::query("INSERT INTO orders (created_at) VALUES (?);")
.bind(datetime)
.execute(&pool)
.await
.unwrap();But each MySqlConnection execute SET time_zone = '+00:00'; after it is established.
sql-core/src/connection.rs:317
self_.execute(r#"
SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE'));
SET time_zone = '+00:00';
SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
"#).await?;Potential Solutions
Execute SET time_zone = SYSTEM; Before insert/update datetime value,
but SET time_zone and Insert maybe using different connection.
Metadata
Metadata
Assignees
Labels
No labels