Skip to content

Commit 5a0ad8c

Browse files
committed
Fix schema search path
1 parent e27e1d9 commit 5a0ad8c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/driver/sqlx_postgres.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use futures::lock::Mutex;
22
use log::LevelFilter;
33
use sea_query::Values;
4-
use std::{future::Future, pin::Pin, sync::Arc};
4+
use std::{fmt::Write, future::Future, pin::Pin, sync::Arc};
55

66
use sqlx::{
77
pool::PoolConnection,
@@ -76,10 +76,13 @@ impl SqlxPostgresConnector {
7676
);
7777
}
7878
}
79-
let set_search_path_sql = options
80-
.schema_search_path
81-
.as_ref()
82-
.map(|schema| format!("SET search_path = \"{schema}\""));
79+
let set_search_path_sql = options.schema_search_path.as_ref().map(|schema| {
80+
let mut string = "SET search_path = ".to_owned();
81+
for schema in schema.split(',') {
82+
write!(&mut string, "\"{schema}\"").unwrap();
83+
}
84+
string
85+
});
8386
let lazy = options.connect_lazy;
8487
let mut pool_options = options.sqlx_pool_options();
8588
if let Some(sql) = set_search_path_sql {

0 commit comments

Comments
 (0)