From 9deef4f9af4f85da198218896431497d32029b9d Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Tue, 24 Dec 2024 00:20:34 +0000 Subject: [PATCH] Fix schema search path --- src/driver/sqlx_postgres.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/driver/sqlx_postgres.rs b/src/driver/sqlx_postgres.rs index 725276893..ab822d53b 100644 --- a/src/driver/sqlx_postgres.rs +++ b/src/driver/sqlx_postgres.rs @@ -78,8 +78,15 @@ impl SqlxPostgresConnector { } let set_search_path_sql = options.schema_search_path.as_ref().map(|schema| { let mut string = "SET search_path = ".to_owned(); - for schema in schema.split(',') { - write!(&mut string, "\"{schema}\"").unwrap(); + 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 });