From 055dbf02d47eb23ce58bb8cd7f5059e820f5fc15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Drouet?= Date: Wed, 19 Jun 2024 10:05:14 +0200 Subject: [PATCH] fix: update setting search path in postgres (#2241) * fix: update setting search path in postgres When using multiple schemas in search path for postgres, using quoted string breaks the ability to use multiple schemas. Removing the quotes fixes it. * Add test cases --------- Co-authored-by: Billy Chan --- sea-orm-migration/tests/main.rs | 2 +- src/driver/sqlx_postgres.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sea-orm-migration/tests/main.rs b/sea-orm-migration/tests/main.rs index 673c51c4..26d579f7 100644 --- a/sea-orm-migration/tests/main.rs +++ b/sea-orm-migration/tests/main.rs @@ -51,7 +51,7 @@ where { let db_connect = |url: String| async { let connect_options = ConnectOptions::new(url) - .set_schema_search_path(schema.to_owned()) + .set_schema_search_path(format!("{schema},public")) .to_owned(); Database::connect(connect_options).await diff --git a/src/driver/sqlx_postgres.rs b/src/driver/sqlx_postgres.rs index ef73001a..b5deaaff 100644 --- a/src/driver/sqlx_postgres.rs +++ b/src/driver/sqlx_postgres.rs @@ -64,7 +64,7 @@ impl SqlxPostgresConnector { let set_search_path_sql = options .schema_search_path .as_ref() - .map(|schema| format!("SET search_path = '{schema}'")); + .map(|schema| format!("SET search_path = {schema}")); let mut pool_options = options.sqlx_pool_options(); if let Some(sql) = set_search_path_sql { pool_options = pool_options.after_connect(move |conn, _| {