From b39ce2098aadc50b9e23685e2cde4c6bce3d361c Mon Sep 17 00:00:00 2001 From: realaravinth Date: Tue, 12 Apr 2022 17:17:24 +0530 Subject: [PATCH] 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. --- src/settings.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/settings.rs b/src/settings.rs index 923647a..f350b2e 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -215,14 +215,15 @@ 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); + set_database_url(&mut s); } - Err(e) => warn!("couldn't interpret DATABASE_URL: {}", e), } - set_database_url(&mut s); - let mut settings: Settings = s.try_into()?; settings.log.set_log_level();