mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-23 18:40:24 +00:00
Bump whoami to v2 (#4143)
* Bump whoami to v2 Signed-off-by: tison <wander4096@gmail.com> * Update sqlx-postgres/src/options/mod.rs --------- Signed-off-by: tison <wander4096@gmail.com>
This commit is contained in:
@@ -65,7 +65,7 @@ num-bigint = { version = "0.4.3", optional = true }
|
||||
smallvec = { version = "1.7.0", features = ["serde"] }
|
||||
stringprep = "0.1.2"
|
||||
tracing = { version = "0.1.37", features = ["log"] }
|
||||
whoami = { version = "1.2.1", default-features = false }
|
||||
whoami = { version = "2.0.2", default-features = false }
|
||||
|
||||
dotenvy.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
@@ -64,7 +64,14 @@ impl PgConnectOptions {
|
||||
.or_else(|| var("PGHOST").ok())
|
||||
.unwrap_or_else(|| default_host(port));
|
||||
|
||||
let username = var("PGUSER").ok().unwrap_or_else(whoami::username);
|
||||
let username = if let Ok(username) = var("PGUSER") {
|
||||
username
|
||||
} else if let Ok(username) = whoami::username() {
|
||||
username
|
||||
} else {
|
||||
// keep the same fallback as previous version
|
||||
"unknown".to_string()
|
||||
};
|
||||
|
||||
let database = var("PGDATABASE").ok();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user