Skip to content

Commit 4ffabc2

Browse files
a little safer
1 parent 8a24148 commit 4ffabc2

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

crates/pg_schema_cache/src/schema_cache.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,21 @@ impl SchemaCache {
4444
fn pool_to_conn_str(pool: &PgPool) -> String {
4545
let conn = pool.connect_options();
4646

47-
format!(
48-
"postgres://{}:<redacted_pw>@{}:{}/{}",
49-
conn.get_username(),
50-
conn.get_host(),
51-
conn.get_port(),
52-
conn.get_database().unwrap_or("default")
53-
)
47+
match conn.get_database() {
48+
None => format!(
49+
"postgres://{}:<redacted_pw>@{}:{}",
50+
conn.get_username(),
51+
conn.get_host(),
52+
conn.get_port()
53+
),
54+
Some(db) => format!(
55+
"postgres://{}:<redacted_pw>@{}:{}/{}",
56+
conn.get_username(),
57+
conn.get_host(),
58+
conn.get_port(),
59+
db
60+
),
61+
}
5462
}
5563

5664
pub fn has_already_cached_connection(&self, pool: &PgPool) -> bool {

0 commit comments

Comments
 (0)