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 9deef4f commit 64582d1
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/driver/sqlx_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ impl SqlxPostgresConnector {
}
let set_search_path_sql = options.schema_search_path.as_ref().map(|schema| {
let mut string = "SET search_path = ".to_owned();
for (i, schema) in schema.split(',').enumerate() {
if i > 0 {
write!(&mut string, ",").unwrap();
}
if schema.starts_with('"') {
write!(&mut string, "{schema}").unwrap();
} else {
write!(&mut string, "\"{schema}\"").unwrap();
if schema.starts_with('"') {
write!(&mut string, "{schema}").unwrap();
} else {
for (i, schema) in schema.split(',').enumerate() {
if i > 0 {
write!(&mut string, ",").unwrap();
}
if schema.starts_with('"') {
write!(&mut string, "{schema}").unwrap();
} else {
write!(&mut string, "\"{schema}\"").unwrap();
}
}
}
string
Expand Down

0 comments on commit 64582d1

Please sign in to comment.