Skip to content

Commit

Permalink
Fix schema search path
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Dec 24, 2024
1 parent e27e1d9 commit 5a0ad8c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/driver/sqlx_postgres.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures::lock::Mutex;
use log::LevelFilter;
use sea_query::Values;
use std::{future::Future, pin::Pin, sync::Arc};
use std::{fmt::Write, future::Future, pin::Pin, sync::Arc};

use sqlx::{
pool::PoolConnection,
Expand Down Expand Up @@ -76,10 +76,13 @@ impl SqlxPostgresConnector {
);
}
}
let set_search_path_sql = options
.schema_search_path
.as_ref()
.map(|schema| format!("SET search_path = \"{schema}\""));
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();
}
string
});
let lazy = options.connect_lazy;
let mut pool_options = options.sqlx_pool_options();
if let Some(sql) = set_search_path_sql {
Expand Down

0 comments on commit 5a0ad8c

Please sign in to comment.