From e818d1adf9f5191068cbb02048b585afb629a216 Mon Sep 17 00:00:00 2001 From: Arne Beer Date: Tue, 7 Jun 2022 11:28:20 +0200 Subject: [PATCH 1/2] Expose ConnectOptions --- sqlx-core/src/pool/mod.rs | 5 +++++ sqlx-core/src/postgres/options/mod.rs | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/sqlx-core/src/pool/mod.rs b/sqlx-core/src/pool/mod.rs index 6ca6739144..34554e23dc 100644 --- a/sqlx-core/src/pool/mod.rs +++ b/sqlx-core/src/pool/mod.rs @@ -435,6 +435,11 @@ impl Pool { pub fn num_idle(&self) -> usize { self.0.num_idle() } + + /// Get the connection options for this pool + pub fn connect_options(&self) -> &::Options { + &self.0.connect_options + } } #[cfg(all( diff --git a/sqlx-core/src/postgres/options/mod.rs b/sqlx-core/src/postgres/options/mod.rs index 638629b6cf..bedeb6bda1 100644 --- a/sqlx-core/src/postgres/options/mod.rs +++ b/sqlx-core/src/postgres/options/mod.rs @@ -260,6 +260,20 @@ impl PgConnectOptions { self } + /// Get the current database name. + /// + /// # Example + /// + /// ```rust + /// # use sqlx_core::postgres::PgConnectOptions; + /// let options = PgConnectOptions::new() + /// .database("postgres"); + /// assert!(options.get_database().is_some()); + /// ``` + pub fn get_database(&self) -> Option<&str> { + self.database.as_deref() + } + /// Sets whether or with what priority a secure SSL TCP/IP connection will be negotiated /// with the server. /// From e87ee3d021551b7550b164b945bee684a0aade1a Mon Sep 17 00:00:00 2001 From: Arne Beer Date: Mon, 13 Jun 2022 22:22:33 +0200 Subject: [PATCH 2/2] Expose PoolOptions --- sqlx-core/src/pool/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sqlx-core/src/pool/mod.rs b/sqlx-core/src/pool/mod.rs index 34554e23dc..81a0ebe523 100644 --- a/sqlx-core/src/pool/mod.rs +++ b/sqlx-core/src/pool/mod.rs @@ -440,6 +440,11 @@ impl Pool { pub fn connect_options(&self) -> &::Options { &self.0.connect_options } + + /// Get the options for this pool + pub fn options(&self) -> &PoolOptions { + &self.0.options + } } #[cfg(all(