From 274826e7d453c6812a5f5d948012a6d188201562 Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Sat, 20 Jun 2020 08:36:17 -0400 Subject: [PATCH] fix(mysql): improve compatibility with ProxySQL Joins the MySQL connection setup statements into a single statement to prevent issues with ProxySQL, which requires special handling of connections that might be shared between multiple backends. Fixes #422 Signed-off-by: Marcus Griep --- sqlx-core/src/mysql/connection/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sqlx-core/src/mysql/connection/mod.rs b/sqlx-core/src/mysql/connection/mod.rs index 11cd08c517..eba5180b5b 100644 --- a/sqlx-core/src/mysql/connection/mod.rs +++ b/sqlx-core/src/mysql/connection/mod.rs @@ -119,11 +119,11 @@ impl Connect for MySqlConnection { // https://mathiasbynens.be/notes/mysql-utf8mb4 - conn.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?; + conn.execute(concat!( + r#"SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE')),"#, + r#"time_zone='+00:00',"#, + r#"NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;"#, + )).await?; Ok(conn) })