Fix schema search path

This commit is contained in:
Chris Tsang 2024-12-24 00:23:05 +00:00
parent 9deef4f9af
commit 64582d1f4e

View File

@ -78,6 +78,9 @@ impl SqlxPostgresConnector {
} }
let set_search_path_sql = options.schema_search_path.as_ref().map(|schema| { let set_search_path_sql = options.schema_search_path.as_ref().map(|schema| {
let mut string = "SET search_path = ".to_owned(); let mut string = "SET search_path = ".to_owned();
if schema.starts_with('"') {
write!(&mut string, "{schema}").unwrap();
} else {
for (i, schema) in schema.split(',').enumerate() { for (i, schema) in schema.split(',').enumerate() {
if i > 0 { if i > 0 {
write!(&mut string, ",").unwrap(); write!(&mut string, ",").unwrap();
@ -88,6 +91,7 @@ impl SqlxPostgresConnector {
write!(&mut string, "\"{schema}\"").unwrap(); write!(&mut string, "\"{schema}\"").unwrap();
} }
} }
}
string string
}); });
let lazy = options.connect_lazy; let lazy = options.connect_lazy;