From 64582d1f4e153a56bcaa57f66b6404fc34f84038 Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Tue, 24 Dec 2024 00:23:05 +0000 Subject: [PATCH] Fix schema search path --- src/driver/sqlx_postgres.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/driver/sqlx_postgres.rs b/src/driver/sqlx_postgres.rs index ab822d53..704db812 100644 --- a/src/driver/sqlx_postgres.rs +++ b/src/driver/sqlx_postgres.rs @@ -78,14 +78,18 @@ impl SqlxPostgresConnector { } let set_search_path_sql = options.schema_search_path.as_ref().map(|schema| { let mut string = "SET search_path = ".to_owned(); - for (i, schema) in schema.split(',').enumerate() { - if i > 0 { - write!(&mut string, ",").unwrap(); - } - if schema.starts_with('"') { - write!(&mut string, "{schema}").unwrap(); - } else { - write!(&mut string, "\"{schema}\"").unwrap(); + if schema.starts_with('"') { + write!(&mut string, "{schema}").unwrap(); + } else { + for (i, schema) in schema.split(',').enumerate() { + if i > 0 { + write!(&mut string, ",").unwrap(); + } + if schema.starts_with('"') { + write!(&mut string, "{schema}").unwrap(); + } else { + write!(&mut string, "\"{schema}\"").unwrap(); + } } } string