From 7b2fa01dff833c1cee418eff7f6a3bb801cd6635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Drouet?= Date: Tue, 28 May 2024 10:00:48 +0200 Subject: [PATCH 1/2] 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. --- src/driver/sqlx_postgres.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/sqlx_postgres.rs b/src/driver/sqlx_postgres.rs index ef73001a6..b5deaaff6 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, _| { From b1d7c463e58f5de4f21bede40c1e892e78892707 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 30 May 2024 18:18:48 +0800 Subject: [PATCH 2/2] Add test cases --- sea-orm-migration/tests/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sea-orm-migration/tests/main.rs b/sea-orm-migration/tests/main.rs index 673c51c48..26d579f79 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