Skip to content

Commit

Permalink
refactor(core): rename PgConnectionInfo to ConnectionExt
Browse files Browse the repository at this point in the history
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
  • Loading branch information
AtkinsChang committed Aug 17, 2021
1 parent 38435ca commit 4632471
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sqlx-core/src/postgres/connection/mod.rs
Expand Up @@ -178,18 +178,18 @@ impl Connection for PgConnection {
}
}

pub trait PgConnectionInfo {
pub trait ConnectionExt {
/// the version number of the server in `libpq` format
fn server_version_num(&self) -> Option<u32>;
}

impl PgConnectionInfo for PgConnection {
impl ConnectionExt for PgConnection {
fn server_version_num(&self) -> Option<u32> {
self.stream.server_version_num
}
}

impl PgConnectionInfo for crate::pool::PoolConnection<Postgres> {
impl ConnectionExt for crate::pool::PoolConnection<Postgres> {
fn server_version_num(&self) -> Option<u32> {
self.stream.server_version_num
}
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/postgres/mod.rs
Expand Up @@ -22,7 +22,7 @@ mod migrate;

pub use arguments::{PgArgumentBuffer, PgArguments};
pub use column::PgColumn;
pub use connection::{PgConnection, PgConnectionInfo};
pub use connection::{ConnectionExt, PgConnection};
pub use database::Postgres;
pub use error::{PgDatabaseError, PgErrorPosition};
pub use listener::{PgListener, PgNotification};
Expand Down
6 changes: 4 additions & 2 deletions tests/postgres/postgres.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -968,6 +968,8 @@ async fn test_listener_cleanup() -> anyhow::Result<()> {

#[sqlx_macros::test]
async fn it_supports_domain_types_in_composite_domain_types() -> anyhow::Result<()> {
use sqlx::postgres::ConnectionExt;

// Only supported in Postgres 11+
let mut conn = new::<Postgres>().await?;
if matches!(conn.server_version_num(), Some(version) if version < 110000) {
Expand Down Expand Up @@ -1096,7 +1098,7 @@ CREATE TABLE heating_bills (

#[sqlx_macros::test]
async fn test_pg_server_num() -> anyhow::Result<()> {
use sqlx::postgres::PgConnectionInfo;
use sqlx::postgres::ConnectionExt;

let conn = new::<Postgres>().await?;

Expand Down

0 comments on commit 4632471

Please sign in to comment.