Skip to content

Commit c4f9a6a

Browse files
committed
refactor(core): move fn server_version_num from trait PgConnectionInfo to impl
Signed-off-by: Atkins Chang <[email protected]>
1 parent 207e6db commit c4f9a6a

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

sqlx-core/src/postgres/connection/mod.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ pub struct PgConnection {
6565
}
6666

6767
impl PgConnection {
68+
/// the version number of the server in `libpq` format
69+
pub fn server_version_num(&self) -> Option<u32> {
70+
self.stream.server_version_num
71+
}
72+
6873
// will return when the connection is ready for another query
6974
async fn wait_until_ready(&mut self) -> Result<(), Error> {
7075
if !self.stream.wbuf.is_empty() {
@@ -177,20 +182,3 @@ impl Connection for PgConnection {
177182
!self.stream.wbuf.is_empty()
178183
}
179184
}
180-
181-
pub trait PgConnectionInfo {
182-
/// the version number of the server in `libpq` format
183-
fn server_version_num(&self) -> Option<u32>;
184-
}
185-
186-
impl PgConnectionInfo for PgConnection {
187-
fn server_version_num(&self) -> Option<u32> {
188-
self.stream.server_version_num
189-
}
190-
}
191-
192-
impl PgConnectionInfo for crate::pool::PoolConnection<Postgres> {
193-
fn server_version_num(&self) -> Option<u32> {
194-
self.stream.server_version_num
195-
}
196-
}

sqlx-core/src/postgres/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod migrate;
2222

2323
pub use arguments::{PgArgumentBuffer, PgArguments};
2424
pub use column::PgColumn;
25-
pub use connection::{PgConnection, PgConnectionInfo};
25+
pub use connection::PgConnection;
2626
pub use database::Postgres;
2727
pub use error::{PgDatabaseError, PgErrorPosition};
2828
pub use listener::{PgListener, PgNotification};

tests/postgres/postgres.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use futures::TryStreamExt;
22
use sqlx::postgres::{
33
PgConnectOptions, PgConnection, PgDatabaseError, PgErrorPosition, PgSeverity,
44
};
5-
use sqlx::postgres::{PgConnectionInfo, PgPoolOptions, PgRow, Postgres};
5+
use sqlx::postgres::{PgPoolOptions, PgRow, Postgres};
66
use sqlx::{Column, Connection, Executor, Row, Statement, TypeInfo};
77
use sqlx_test::{new, setup_if_needed};
88
use std::env;
@@ -1096,8 +1096,6 @@ CREATE TABLE heating_bills (
10961096

10971097
#[sqlx_macros::test]
10981098
async fn test_pg_server_num() -> anyhow::Result<()> {
1099-
use sqlx::postgres::PgConnectionInfo;
1100-
11011099
let conn = new::<Postgres>().await?;
11021100

11031101
assert!(conn.server_version_num().is_some());

0 commit comments

Comments
 (0)