Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion refinery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion refinery_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
18 changes: 10 additions & 8 deletions refinery_core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ impl TryFrom<Url> for Config {
}
};

#[cfg(any(
feature = "postgres",
feature = "tokio-postgres",
feature = "tiberius-config"
))]
let query_params: std::collections::HashMap<Cow<'_, str>, Cow<'_, str>> =
url.query_pairs().collect();

Ok(Self {
main: Main {
db_type,
Expand Down Expand Up @@ -274,11 +282,7 @@ impl TryFrom<Url> 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::<std::collections::HashMap<Cow<'_, str>, Cow<'_, str>>>()
.get("sslmode")
{
use_tls: match query_params.get("sslmode") {
Some(Cow::Borrowed("require")) => true,
Some(Cow::Borrowed("disable")) | None => false,
_ => {
Expand All @@ -291,9 +295,7 @@ impl TryFrom<Url> for Config {
}
},
#[cfg(feature = "tiberius-config")]
trust_cert: url
.query_pairs()
.collect::<std::collections::HashMap<Cow<'_, str>, Cow<'_, str>>>()
trust_cert: query_params
.get("trust_cert")
.unwrap_or(&Cow::Borrowed("false"))
.parse::<bool>()
Expand Down
4 changes: 2 additions & 2 deletions refinery_core/src/drivers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Loading