diff --git a/CHANGELOG.md b/CHANGELOG.md index f88530e2..4e6a6bd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update `rusqlite` to support up until version 0.37. [#389](https://github.com/rust-db/refinery/pull/389), [#390](https://github.com/rust-db/refinery/pull/390) - Update `thiserror` to version 2. [#372](https://github.com/rust-db/refinery/pull/372) - Update MSRV (Minimum Supported Rust Version). [#401](https://github.com/rust-db/refinery/pull/401), [#362](https://github.com/rust-db/refinery/pull/362) -- Fix unused warnings [#403](https://github.com/rust-db/refinery/pull/401) +- Fix unused warnings [#403](https://github.com/rust-db/refinery/pull/403) ### Fixed diff --git a/refinery/Cargo.toml b/refinery/Cargo.toml index 1218459b..1f53fa1d 100644 --- a/refinery/Cargo.toml +++ b/refinery/Cargo.toml @@ -39,6 +39,6 @@ futures = "0.3" assert_cmd = "2.0" predicates = "3" tempfile = "3" -time = "0.3.5" +time = "0.3.47" tokio-util = { version = "0.7.7", features = ["compat"] } tokio = { version = "1.9.0", features = ["full"] } diff --git a/refinery_core/Cargo.toml b/refinery_core/Cargo.toml index 24ec6361..51ce579e 100644 --- a/refinery_core/Cargo.toml +++ b/refinery_core/Cargo.toml @@ -47,7 +47,7 @@ tiberius = { version = ">= 0.7, <= 0.12", optional = true, default-features = fa tokio = { version = "1.0", optional = true } futures = { version = "0.3.16", optional = true, features = ["async-await"] } tokio-util = { version = "0.7.7", features = ["compat"], optional = true } -time = { version = "0.3.5", features = ["parsing", "formatting"] } +time = { version = "0.3.47", features = ["parsing", "formatting"] } serde = { version = "1", features = ["derive"], optional = true } toml = { version = "0.8.8", optional = true } diff --git a/refinery_core/src/config.rs b/refinery_core/src/config.rs index ca1b0101..3dc0dccf 100644 --- a/refinery_core/src/config.rs +++ b/refinery_core/src/config.rs @@ -222,6 +222,14 @@ impl TryFrom for Config { } }; + #[cfg(any( + feature = "postgres", + feature = "tokio-postgres", + feature = "tiberius-config" + ))] + let query_params: std::collections::HashMap, Cow<'_, str>> = + url.query_pairs().collect(); + Ok(Self { main: Main { db_type, @@ -274,11 +282,7 @@ impl TryFrom for Config { ))] db_name: Some(url.path().trim_start_matches('/').to_string()), #[cfg(any(feature = "postgres", feature = "tokio-postgres"))] - use_tls: match url - .query_pairs() - .collect::, Cow<'_, str>>>() - .get("sslmode") - { + use_tls: match query_params.get("sslmode") { Some(Cow::Borrowed("require")) => true, Some(Cow::Borrowed("disable")) | None => false, _ => { @@ -291,9 +295,7 @@ impl TryFrom for Config { } }, #[cfg(feature = "tiberius-config")] - trust_cert: url - .query_pairs() - .collect::, Cow<'_, str>>>() + trust_cert: query_params .get("trust_cert") .unwrap_or(&Cow::Borrowed("false")) .parse::() diff --git a/refinery_core/src/drivers/config.rs b/refinery_core/src/drivers/config.rs index 3f1cfd74..1093a6ce 100644 --- a/refinery_core/src/drivers/config.rs +++ b/refinery_core/src/drivers/config.rs @@ -96,7 +96,7 @@ macro_rules! with_connection { let conn; if $config.use_tls() { - let connector = native_tls::TlsConnector::new().unwrap(); + let connector = native_tls::TlsConnector::new().migration_err("could not create TLS connector", None)?; let connector = postgres_native_tls::MakeTlsConnector::new(connector); conn = postgres::Client::connect(path.as_str(), connector).migration_err("could not connect to database", None)?; } else { @@ -144,7 +144,7 @@ macro_rules! with_connection_async { if #[cfg(feature = "tokio-postgres")] { let path = crate::config::build_db_url("postgresql", $config); if $config.use_tls() { - let connector = native_tls::TlsConnector::new().unwrap(); + let connector = native_tls::TlsConnector::new().migration_err("could not create TLS connector", None)?; let connector = postgres_native_tls::MakeTlsConnector::new(connector); let (client, connection) = tokio_postgres::connect(path.as_str(), connector).await.migration_err("could not connect to database", None)?; tokio::spawn(async move {