fix: loading sqlite database URL from env var

SUMMARY
    sqlite caused problems(panic) when trying to break its database URL
    when trying to break it down into host, protocol, path and port,
    etc. with crate::settings;:DatabaseBuilder. Bypassing
    DatabaseBuilder and directly setting crate::settings::Database.url,
    fixes this issue.
This commit is contained in:
Aravinth Manivannan 2022-04-12 17:17:24 +05:30
parent ea0e299fef
commit b39ce2098a
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88

View file

@ -215,13 +215,14 @@ impl Settings {
match env::var("DATABASE_URL") {
Ok(val) => {
let url = Url::parse(&val).expect("couldn't parse Database URL");
let database_conf = DatabaseBuilder::extract_database_url(&url);
set_from_database_url(&mut s, &database_conf);
s.set("database.url", url.to_string())
.expect("unable to set database URL");
}
Err(e) => warn!("couldn't interpret DATABASE_URL: {}", e),
}
Err(e) => {
warn!("couldn't interpret DATABASE_URL: {}", e);
set_database_url(&mut s);
}
}
let mut settings: Settings = s.try_into()?;