mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
Move server_version_num
from trait to impl (#1384)
* refactor(core): move `fn server_version_num` from `trait PgConnectionInfo` to impl Signed-off-by: Atkins Chang <atkinschang@gmail.com> * fix rebase issues Co-authored-by: Austin Bonander <austin@launchbadge.com>
This commit is contained in:
parent
17fde443be
commit
17760d0f83
4 changed files with 12 additions and 26 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -989,9 +989,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.13.25"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6"
|
||||
checksum = "3826a6e0e2215d7a41c2bfc7c9244123969273f3476b939a226aac0ab56e9e3c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
|
@ -1225,9 +1225,9 @@ checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
|
|||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.12.26+1.3.0"
|
||||
version = "0.13.2+1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494"
|
||||
checksum = "3a42de9a51a5c12e00fc0e4ca6bc2ea43582fc6418488e8f615e905d886f258b"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
|
|
@ -67,6 +67,11 @@ pub struct PgConnection {
|
|||
}
|
||||
|
||||
impl PgConnection {
|
||||
/// the version number of the server in `libpq` format
|
||||
pub fn server_version_num(&self) -> Option<u32> {
|
||||
self.stream.server_version_num
|
||||
}
|
||||
|
||||
// will return when the connection is ready for another query
|
||||
pub(in crate::postgres) async fn wait_until_ready(&mut self) -> Result<(), Error> {
|
||||
if !self.stream.wbuf.is_empty() {
|
||||
|
@ -187,20 +192,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<u32>;
|
||||
}
|
||||
|
||||
impl PgConnectionInfo for PgConnection {
|
||||
fn server_version_num(&self) -> Option<u32> {
|
||||
self.stream.server_version_num
|
||||
}
|
||||
}
|
||||
|
||||
impl PgConnectionInfo for crate::pool::PoolConnection<Postgres> {
|
||||
fn server_version_num(&self) -> Option<u32> {
|
||||
self.stream.server_version_num
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ mod migrate;
|
|||
pub use advisory_lock::{PgAdvisoryLock, PgAdvisoryLockGuard, PgAdvisoryLockKey};
|
||||
pub use arguments::{PgArgumentBuffer, PgArguments};
|
||||
pub use column::PgColumn;
|
||||
pub use connection::{PgConnection, PgConnectionInfo};
|
||||
pub use connection::PgConnection;
|
||||
pub use copy::PgCopyIn;
|
||||
pub use database::Postgres;
|
||||
pub use error::{PgDatabaseError, PgErrorPosition};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use futures::{StreamExt, TryStreamExt};
|
||||
use sqlx::postgres::types::Oid;
|
||||
use sqlx::postgres::{
|
||||
PgAdvisoryLock, PgConnectOptions, PgConnection, PgConnectionInfo, PgDatabaseError,
|
||||
PgErrorPosition, PgListener, PgPoolOptions, PgRow, PgSeverity, Postgres,
|
||||
PgAdvisoryLock, PgConnectOptions, PgConnection, PgDatabaseError, PgErrorPosition, PgListener,
|
||||
PgPoolOptions, PgRow, PgSeverity, Postgres,
|
||||
};
|
||||
use sqlx::{Column, Connection, Executor, Row, Statement, TypeInfo};
|
||||
use sqlx_test::{new, pool, setup_if_needed};
|
||||
|
@ -1202,8 +1202,6 @@ VALUES
|
|||
|
||||
#[sqlx_macros::test]
|
||||
async fn test_pg_server_num() -> anyhow::Result<()> {
|
||||
use sqlx::postgres::PgConnectionInfo;
|
||||
|
||||
let conn = new::<Postgres>().await?;
|
||||
|
||||
assert!(conn.server_version_num().is_some());
|
||||
|
|
Loading…
Reference in a new issue