mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
chore: Fix warnings for custom postgres_## cfg flags (#3950)
* chore: Fix warnings for custom postgres_## cfg flags Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com> * pr feedback - reorder cfg allowance; enable test_pg_copy_chunked test Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com> * refactor(postgres): Remove two more deprecated cfg flag uses (from docstrings) Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com> * refactor(ci): Use separate job for postgres ssl auth tests Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com> --------- Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
This commit is contained in:
parent
1f7af3abc2
commit
e77f32ea5e
28
.github/workflows/sqlx.yml
vendored
28
.github/workflows/sqlx.yml
vendored
@ -221,9 +221,7 @@ jobs:
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- env:
|
||||
# FIXME: needed to disable `ltree` tests in Postgres 9.6
|
||||
# but `PgLTree` should just fall back to text format
|
||||
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
|
||||
RUSTFLAGS: -D warnings --cfg postgres="${{ matrix.postgres }}"
|
||||
run: >
|
||||
cargo build
|
||||
--no-default-features
|
||||
@ -245,9 +243,7 @@ jobs:
|
||||
env:
|
||||
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
|
||||
SQLX_OFFLINE_DIR: .sqlx
|
||||
# FIXME: needed to disable `ltree` tests in Postgres 9.6
|
||||
# but `PgLTree` should just fall back to text format
|
||||
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
|
||||
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
|
||||
|
||||
# Run the `test-attr` test again to cover cleanup.
|
||||
- run: >
|
||||
@ -258,9 +254,7 @@ jobs:
|
||||
env:
|
||||
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
|
||||
SQLX_OFFLINE_DIR: .sqlx
|
||||
# FIXME: needed to disable `ltree` tests in Postgres 9.6
|
||||
# but `PgLTree` should just fall back to text format
|
||||
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
|
||||
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
|
||||
|
||||
- if: matrix.tls != 'none'
|
||||
run: >
|
||||
@ -270,9 +264,7 @@ jobs:
|
||||
env:
|
||||
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt
|
||||
SQLX_OFFLINE_DIR: .sqlx
|
||||
# FIXME: needed to disable `ltree` tests in Postgres 9.6
|
||||
# but `PgLTree` should just fall back to text format
|
||||
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
|
||||
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
|
||||
|
||||
# Remove test artifacts
|
||||
- run: cargo clean -p sqlx
|
||||
@ -286,9 +278,7 @@ jobs:
|
||||
env:
|
||||
SQLX_OFFLINE: true
|
||||
SQLX_OFFLINE_DIR: .sqlx
|
||||
# FIXME: needed to disable `ltree` tests in Postgres 9.6
|
||||
# but `PgLTree` should just fall back to text format
|
||||
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
|
||||
RUSTFLAGS: -D warnings --cfg postgres="${{ matrix.postgres }}"
|
||||
|
||||
# Test macros in offline mode (still needs DATABASE_URL to run)
|
||||
- run: >
|
||||
@ -300,9 +290,7 @@ jobs:
|
||||
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
|
||||
SQLX_OFFLINE: true
|
||||
SQLX_OFFLINE_DIR: .sqlx
|
||||
# FIXME: needed to disable `ltree` tests in Postgres 9.6
|
||||
# but `PgLTree` should just fall back to text format
|
||||
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
|
||||
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
|
||||
|
||||
postgres-ssl-auth:
|
||||
name: Postgres SSL Auth
|
||||
@ -334,9 +322,7 @@ jobs:
|
||||
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
|
||||
env:
|
||||
DATABASE_URL: postgres://postgres@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt&sslkey=.%2Ftests%2Fcerts%2Fkeys%2Fclient.key&sslcert=.%2Ftests%2Fcerts%2Fclient.crt
|
||||
# FIXME: needed to disable `ltree` tests in Postgres 9.6
|
||||
# but `PgLTree` should just fall back to text format
|
||||
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}_client_ssl
|
||||
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
|
||||
|
||||
mysql:
|
||||
name: MySQL
|
||||
|
||||
@ -244,6 +244,7 @@ disallowed_methods = 'deny'
|
||||
level = 'warn'
|
||||
check-cfg = [
|
||||
'cfg(mariadb, values(any()))',
|
||||
'cfg(postgres, values(any()))',
|
||||
'cfg(sqlite_ipaddr)',
|
||||
'cfg(sqlite_test_sqlcipher)',
|
||||
]
|
||||
@ -434,7 +435,6 @@ name = "postgres-migrate"
|
||||
path = "tests/postgres/migrate.rs"
|
||||
required-features = ["postgres", "macros", "migrate"]
|
||||
|
||||
|
||||
[[test]]
|
||||
name = "postgres-query-builder"
|
||||
path = "tests/postgres/query_builder.rs"
|
||||
|
||||
@ -13,9 +13,8 @@ use std::ops::{Deref, DerefMut};
|
||||
/// connection or [`begin`][`Acquire::begin`] a transaction, then you can do it
|
||||
/// like that:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```rust,ignore
|
||||
/// # use sqlx::{Acquire, postgres::Postgres, error::BoxDynError};
|
||||
/// # #[cfg(any(postgres_9_6, postgres_15))]
|
||||
/// async fn run_query<'a, A>(conn: A) -> Result<(), BoxDynError>
|
||||
/// where
|
||||
/// A: Acquire<'a, Database = Postgres>,
|
||||
@ -32,10 +31,9 @@ use std::ops::{Deref, DerefMut};
|
||||
/// If you run into a lifetime error about "implementation of `sqlx::Acquire` is
|
||||
/// not general enough", the [workaround] looks like this:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```rust,ignore
|
||||
/// # use std::future::Future;
|
||||
/// # use sqlx::{Acquire, postgres::Postgres, error::BoxDynError};
|
||||
/// # #[cfg(any(postgres_9_6, postgres_15))]
|
||||
/// fn run_query<'a, 'c, A>(conn: A) -> impl Future<Output = Result<(), BoxDynError>> + Send + 'a
|
||||
/// where
|
||||
/// A: Acquire<'c, Database = Postgres> + Send + 'a,
|
||||
@ -55,9 +53,8 @@ use std::ops::{Deref, DerefMut};
|
||||
/// connection as an argument to a function, then it's easier to just accept a
|
||||
/// mutable reference to a database connection like so:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```rust,ignore
|
||||
/// # use sqlx::{postgres::PgConnection, error::BoxDynError};
|
||||
/// # #[cfg(any(postgres_9_6, postgres_15))]
|
||||
/// async fn run_query(conn: &mut PgConnection) -> Result<(), BoxDynError> {
|
||||
/// sqlx::query!("SELECT 1 as v").fetch_one(&mut *conn).await?;
|
||||
/// sqlx::query!("SELECT 2 as v").fetch_one(&mut *conn).await?;
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
//! | [MariaDB] | 10.1+ | [`mysql`] |
|
||||
//! | [Microsoft SQL Server] | 2019 | [`mssql`] (Pending a full rewrite) |
|
||||
//! | [MySQL] | 5.6, 5.7, 8.0 | [`mysql`] |
|
||||
//! | [PostgreSQL] | 9.5+ | [`postgres`] |
|
||||
//! | [PostgreSQL] | 13+ | [`postgres`] |
|
||||
//! | [SQLite] | 3.20.1+ | [`sqlite`] |
|
||||
//!
|
||||
//! [MariaDB]: https://mariadb.com/
|
||||
|
||||
@ -205,8 +205,8 @@ where
|
||||
}
|
||||
|
||||
// appears to have been used in the past to communicate potential NULLS
|
||||
// but reading source code back through our supported postgres versions (9.5+)
|
||||
// this is never used for anything
|
||||
// but reading source code back through our historically supported
|
||||
// postgres versions (9.5+) this is never used for anything
|
||||
let _flags = buf.get_i32();
|
||||
|
||||
// the OID of the element
|
||||
|
||||
@ -2142,6 +2142,8 @@ create temporary table person(
|
||||
assert_eq!(people, p_query);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx_macros::test]
|
||||
async fn test_pg_copy_chunked() -> anyhow::Result<()> {
|
||||
let mut conn = new::<Postgres>().await?;
|
||||
|
||||
|
||||
@ -519,7 +519,7 @@ test_type!(numrange_bigdecimal<PgRange<sqlx::types::BigDecimal>>(Postgres,
|
||||
Bound::Excluded("2.4".parse::<sqlx::types::BigDecimal>().unwrap())))
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_14, postgres_15))]
|
||||
#[cfg(not(postgres = "13"))]
|
||||
test_type!(cube<sqlx::postgres::types::PgCube>(Postgres,
|
||||
"cube(2)" == sqlx::postgres::types::PgCube::Point(2.),
|
||||
"cube(2.1)" == sqlx::postgres::types::PgCube::Point(2.1),
|
||||
@ -530,51 +530,43 @@ test_type!(cube<sqlx::postgres::types::PgCube>(Postgres,
|
||||
"cube(array[2,3,4],array[4,5,6])" == sqlx::postgres::types::PgCube::MultiDimension(vec![vec![2.,3.,4.],vec![4.,5.,6.]]),
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_14, postgres_15))]
|
||||
#[cfg(not(postgres = "13"))]
|
||||
test_type!(_cube<Vec<sqlx::postgres::types::PgCube>>(Postgres,
|
||||
"array[cube(2),cube(2)]" == vec![sqlx::postgres::types::PgCube::Point(2.), sqlx::postgres::types::PgCube::Point(2.)],
|
||||
"array[cube(2.2,-3.4)]" == vec![sqlx::postgres::types::PgCube::OneDimensionInterval(2.2, -3.4)],
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(point<sqlx::postgres::types::PgPoint>(Postgres,
|
||||
"point(2.2,-3.4)" ~= sqlx::postgres::types::PgPoint { x: 2.2, y:-3.4 },
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(_point<Vec<sqlx::postgres::types::PgPoint>>(Postgres,
|
||||
"array[point(2,3),point(2.1,3.4)]" @= vec![sqlx::postgres::types::PgPoint { x:2., y: 3. }, sqlx::postgres::types::PgPoint { x:2.1, y: 3.4 }],
|
||||
"array[point(2.2,-3.4)]" @= vec![sqlx::postgres::types::PgPoint { x: 2.2, y: -3.4 }],
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(line<sqlx::postgres::types::PgLine>(Postgres,
|
||||
"line('{1.1, -2.2, 3.3}')" == sqlx::postgres::types::PgLine { a: 1.1, b:-2.2, c: 3.3 },
|
||||
"line('((0.0, 0.0), (1.0,1.0))')" == sqlx::postgres::types::PgLine { a: 1., b: -1., c: 0. },
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(lseg<sqlx::postgres::types::PgLSeg>(Postgres,
|
||||
"lseg('((1.0, 2.0), (3.0,4.0))')" == sqlx::postgres::types::PgLSeg { start_x: 1., start_y: 2., end_x: 3. , end_y: 4.},
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(box<sqlx::postgres::types::PgBox>(Postgres,
|
||||
"box('((1.0, 2.0), (3.0,4.0))')" == sqlx::postgres::types::PgBox { upper_right_x: 3., upper_right_y: 4., lower_left_x: 1. , lower_left_y: 2.},
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(_box<Vec<sqlx::postgres::types::PgBox>>(Postgres,
|
||||
"array[box('1,2,3,4'),box('((1.1, 2.2), (3.3, 4.4))')]" @= vec![sqlx::postgres::types::PgBox { upper_right_x: 3., upper_right_y: 4., lower_left_x: 1., lower_left_y: 2. }, sqlx::postgres::types::PgBox { upper_right_x: 3.3, upper_right_y: 4.4, lower_left_x: 1.1, lower_left_y: 2.2 }],
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(path<sqlx::postgres::types::PgPath>(Postgres,
|
||||
"path('((1.0, 2.0), (3.0,4.0))')" == sqlx::postgres::types::PgPath { closed: true, points: vec![ sqlx::postgres::types::PgPoint { x: 1., y: 2. }, sqlx::postgres::types::PgPoint { x: 3. , y: 4. } ]},
|
||||
"path('[(1.0, 2.0), (3.0,4.0)]')" == sqlx::postgres::types::PgPath { closed: false, points: vec![ sqlx::postgres::types::PgPoint { x: 1., y: 2. }, sqlx::postgres::types::PgPoint { x: 3. , y: 4. } ]},
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(polygon<sqlx::postgres::types::PgPolygon>(Postgres,
|
||||
"polygon('((-2,-3),(-1,-3),(-1,-1),(1,1),(1,3),(2,3),(2,-3),(1,-3),(1,0),(-1,0),(-1,-2),(-2,-2))')" ~= sqlx::postgres::types::PgPolygon { points: vec![
|
||||
sqlx::postgres::types::PgPoint { x: -2., y: -3. }, sqlx::postgres::types::PgPoint { x: -1., y: -3. }, sqlx::postgres::types::PgPoint { x: -1., y: -1. }, sqlx::postgres::types::PgPoint { x: 1., y: 1. },
|
||||
@ -583,7 +575,6 @@ test_type!(polygon<sqlx::postgres::types::PgPolygon>(Postgres,
|
||||
]},
|
||||
));
|
||||
|
||||
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
|
||||
test_type!(circle<sqlx::postgres::types::PgCircle>(Postgres,
|
||||
"circle('<(1.1, -2.2), 3.3>')" ~= sqlx::postgres::types::PgCircle { x: 1.1, y:-2.2, radius: 3.3 },
|
||||
"circle('((1.1, -2.2), 3.3)')" ~= sqlx::postgres::types::PgCircle { x: 1.1, y:-2.2, radius: 3.3 },
|
||||
@ -678,17 +669,11 @@ test_prepared_type!(citext_array<Vec<PgCiText>>(Postgres,
|
||||
],
|
||||
));
|
||||
|
||||
// FIXME: needed to disable `ltree` tests in version that don't have a binary format for it
|
||||
// but `PgLTree` should just fall back to text format
|
||||
#[cfg(any(postgres_14, postgres_15))]
|
||||
test_type!(ltree<sqlx::postgres::types::PgLTree>(Postgres,
|
||||
"'Foo.Bar.Baz.Quux'::ltree" == sqlx::postgres::types::PgLTree::from_str("Foo.Bar.Baz.Quux").unwrap(),
|
||||
"'Alpha.Beta.Delta.Gamma'::ltree" == sqlx::postgres::types::PgLTree::try_from_iter(["Alpha", "Beta", "Delta", "Gamma"]).unwrap(),
|
||||
));
|
||||
|
||||
// FIXME: needed to disable `ltree` tests in version that don't have a binary format for it
|
||||
// but `PgLTree` should just fall back to text format
|
||||
#[cfg(any(postgres_14, postgres_15))]
|
||||
test_type!(ltree_vec<Vec<sqlx::postgres::types::PgLTree>>(Postgres,
|
||||
"array['Foo.Bar.Baz.Quux', 'Alpha.Beta.Delta.Gamma']::ltree[]" ==
|
||||
vec![
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user