diff --git a/sqlx-core/src/postgres/connection/mod.rs b/sqlx-core/src/postgres/connection/mod.rs index ea49a532cf..59fcd7d70c 100644 --- a/sqlx-core/src/postgres/connection/mod.rs +++ b/sqlx-core/src/postgres/connection/mod.rs @@ -65,6 +65,11 @@ pub struct PgConnection { } impl PgConnection { + /// the version number of the server in `libpq` format + pub fn server_version_num(&self) -> Option { + self.stream.server_version_num + } + // will return when the connection is ready for another query async fn wait_until_ready(&mut self) -> Result<(), Error> { if !self.stream.wbuf.is_empty() { @@ -177,20 +182,3 @@ impl Connection for PgConnection { !self.stream.wbuf.is_empty() } } - -pub trait PgConnectionInfo { - /// the version number of the server in `libpq` format - fn server_version_num(&self) -> Option; -} - -impl PgConnectionInfo for PgConnection { - fn server_version_num(&self) -> Option { - self.stream.server_version_num - } -} - -impl PgConnectionInfo for crate::pool::PoolConnection { - fn server_version_num(&self) -> Option { - self.stream.server_version_num - } -} diff --git a/sqlx-core/src/postgres/mod.rs b/sqlx-core/src/postgres/mod.rs index ed6af06a33..bd72bc6e86 100644 --- a/sqlx-core/src/postgres/mod.rs +++ b/sqlx-core/src/postgres/mod.rs @@ -22,7 +22,7 @@ mod migrate; pub use arguments::{PgArgumentBuffer, PgArguments}; pub use column::PgColumn; -pub use connection::{PgConnection, PgConnectionInfo}; +pub use connection::PgConnection; pub use database::Postgres; pub use error::{PgDatabaseError, PgErrorPosition}; pub use listener::{PgListener, PgNotification}; diff --git a/tests/postgres/postgres.rs b/tests/postgres/postgres.rs index a88c0085e7..4eaf835c9c 100644 --- a/tests/postgres/postgres.rs +++ b/tests/postgres/postgres.rs @@ -2,7 +2,7 @@ use futures::TryStreamExt; use sqlx::postgres::{ PgConnectOptions, PgConnection, PgDatabaseError, PgErrorPosition, PgSeverity, }; -use sqlx::postgres::{PgConnectionInfo, PgPoolOptions, PgRow, Postgres}; +use sqlx::postgres::{PgPoolOptions, PgRow, Postgres}; use sqlx::{Column, Connection, Executor, Row, Statement, TypeInfo}; use sqlx_test::{new, setup_if_needed}; use std::env; @@ -1096,8 +1096,6 @@ CREATE TABLE heating_bills ( #[sqlx_macros::test] async fn test_pg_server_num() -> anyhow::Result<()> { - use sqlx::postgres::PgConnectionInfo; - let conn = new::().await?; assert!(conn.server_version_num().is_some());