Skip to content

Commit 3d250e0

Browse files
committed
chore: Fix warnings for custom postgres_## cfg flags
Signed-off-by: Joshua Potts <[email protected]>
1 parent c825bd3 commit 3d250e0

File tree

6 files changed

+15
-42
lines changed

6 files changed

+15
-42
lines changed

.github/workflows/sqlx.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ jobs:
215215
- uses: Swatinem/rust-cache@v2
216216

217217
- env:
218-
# FIXME: needed to disable `ltree` tests in Postgres 9.6
219-
# but `PgLTree` should just fall back to text format
220-
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
218+
RUSTFLAGS: -D warnings --cfg postgres="${{ matrix.postgres }}"
221219
run: >
222220
cargo build
223221
--no-default-features
@@ -237,9 +235,7 @@ jobs:
237235
env:
238236
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
239237
SQLX_OFFLINE_DIR: .sqlx
240-
# FIXME: needed to disable `ltree` tests in Postgres 9.6
241-
# but `PgLTree` should just fall back to text format
242-
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
238+
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
243239
244240
# Run the `test-attr` test again to cover cleanup.
245241
- run: >
@@ -250,9 +246,7 @@ jobs:
250246
env:
251247
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
252248
SQLX_OFFLINE_DIR: .sqlx
253-
# FIXME: needed to disable `ltree` tests in Postgres 9.6
254-
# but `PgLTree` should just fall back to text format
255-
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
249+
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
256250
257251
- if: matrix.tls != 'none'
258252
run: >
@@ -262,9 +256,7 @@ jobs:
262256
env:
263257
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt
264258
SQLX_OFFLINE_DIR: .sqlx
265-
# FIXME: needed to disable `ltree` tests in Postgres 9.6
266-
# but `PgLTree` should just fall back to text format
267-
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
259+
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
268260

269261
# Remove test artifacts
270262
- run: cargo clean -p sqlx
@@ -278,9 +270,7 @@ jobs:
278270
env:
279271
SQLX_OFFLINE: true
280272
SQLX_OFFLINE_DIR: .sqlx
281-
# FIXME: needed to disable `ltree` tests in Postgres 9.6
282-
# but `PgLTree` should just fall back to text format
283-
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
273+
RUSTFLAGS: -D warnings --cfg postgres="${{ matrix.postgres }}"
284274
285275
# Test macros in offline mode (still needs DATABASE_URL to run)
286276
- run: >
@@ -292,9 +282,7 @@ jobs:
292282
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
293283
SQLX_OFFLINE: true
294284
SQLX_OFFLINE_DIR: .sqlx
295-
# FIXME: needed to disable `ltree` tests in Postgres 9.6
296-
# but `PgLTree` should just fall back to text format
297-
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
285+
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
298286
299287
# client SSL authentication
300288

@@ -310,9 +298,7 @@ jobs:
310298
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
311299
env:
312300
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
313-
# FIXME: needed to disable `ltree` tests in Postgres 9.6
314-
# but `PgLTree` should just fall back to text format
315-
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}_client_ssl
301+
RUSTFLAGS: --cfg postgres="${{ matrix.postgres }}"
316302

317303
mysql:
318304
name: MySQL

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ level = 'warn'
245245
check-cfg = [
246246
'cfg(mariadb, values(any()))',
247247
'cfg(sqlite_ipaddr)',
248+
'cfg(postgres, values(any()))',
248249
'cfg(sqlite_test_sqlcipher)',
249250
]
250251

@@ -434,7 +435,6 @@ name = "postgres-migrate"
434435
path = "tests/postgres/migrate.rs"
435436
required-features = ["postgres", "macros", "migrate"]
436437

437-
438438
[[test]]
439439
name = "postgres-query-builder"
440440
path = "tests/postgres/query_builder.rs"

sqlx-core/src/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! | [MariaDB] | 10.1+ | [`mysql`] |
1313
//! | [Microsoft SQL Server] | 2019 | [`mssql`] (Pending a full rewrite) |
1414
//! | [MySQL] | 5.6, 5.7, 8.0 | [`mysql`] |
15-
//! | [PostgreSQL] | 9.5+ | [`postgres`] |
15+
//! | [PostgreSQL] | 13+ | [`postgres`] |
1616
//! | [SQLite] | 3.20.1+ | [`sqlite`] |
1717
//!
1818
//! [MariaDB]: https://mariadb.com/

sqlx-postgres/src/types/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ where
205205
}
206206

207207
// appears to have been used in the past to communicate potential NULLS
208-
// but reading source code back through our supported postgres versions (9.5+)
209-
// this is never used for anything
208+
// but reading source code back through our historically supported
209+
// postgres versions (9.5+) this is never used for anything
210210
let _flags = buf.get_i32();
211211

212212
// the OID of the element

tests/postgres/postgres.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,8 @@ create temporary table person(
21422142
assert_eq!(people, p_query);
21432143
Ok(())
21442144
}
2145+
2146+
#[allow(unused)]
21452147
async fn test_pg_copy_chunked() -> anyhow::Result<()> {
21462148
let mut conn = new::<Postgres>().await?;
21472149

tests/postgres/types.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ test_type!(numrange_bigdecimal<PgRange<sqlx::types::BigDecimal>>(Postgres,
519519
Bound::Excluded("2.4".parse::<sqlx::types::BigDecimal>().unwrap())))
520520
));
521521

522-
#[cfg(any(postgres_14, postgres_15))]
522+
#[cfg(not(postgres = "13"))]
523523
test_type!(cube<sqlx::postgres::types::PgCube>(Postgres,
524524
"cube(2)" == sqlx::postgres::types::PgCube::Point(2.),
525525
"cube(2.1)" == sqlx::postgres::types::PgCube::Point(2.1),
@@ -530,51 +530,43 @@ test_type!(cube<sqlx::postgres::types::PgCube>(Postgres,
530530
"cube(array[2,3,4],array[4,5,6])" == sqlx::postgres::types::PgCube::MultiDimension(vec![vec![2.,3.,4.],vec![4.,5.,6.]]),
531531
));
532532

533-
#[cfg(any(postgres_14, postgres_15))]
533+
#[cfg(not(postgres = "13"))]
534534
test_type!(_cube<Vec<sqlx::postgres::types::PgCube>>(Postgres,
535535
"array[cube(2),cube(2)]" == vec![sqlx::postgres::types::PgCube::Point(2.), sqlx::postgres::types::PgCube::Point(2.)],
536536
"array[cube(2.2,-3.4)]" == vec![sqlx::postgres::types::PgCube::OneDimensionInterval(2.2, -3.4)],
537537
));
538538

539-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
540539
test_type!(point<sqlx::postgres::types::PgPoint>(Postgres,
541540
"point(2.2,-3.4)" ~= sqlx::postgres::types::PgPoint { x: 2.2, y:-3.4 },
542541
));
543542

544-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
545543
test_type!(_point<Vec<sqlx::postgres::types::PgPoint>>(Postgres,
546544
"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 }],
547545
"array[point(2.2,-3.4)]" @= vec![sqlx::postgres::types::PgPoint { x: 2.2, y: -3.4 }],
548546
));
549547

550-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
551548
test_type!(line<sqlx::postgres::types::PgLine>(Postgres,
552549
"line('{1.1, -2.2, 3.3}')" == sqlx::postgres::types::PgLine { a: 1.1, b:-2.2, c: 3.3 },
553550
"line('((0.0, 0.0), (1.0,1.0))')" == sqlx::postgres::types::PgLine { a: 1., b: -1., c: 0. },
554551
));
555552

556-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
557553
test_type!(lseg<sqlx::postgres::types::PgLSeg>(Postgres,
558554
"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.},
559555
));
560556

561-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
562557
test_type!(box<sqlx::postgres::types::PgBox>(Postgres,
563558
"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.},
564559
));
565560

566-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
567561
test_type!(_box<Vec<sqlx::postgres::types::PgBox>>(Postgres,
568562
"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 }],
569563
));
570564

571-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
572565
test_type!(path<sqlx::postgres::types::PgPath>(Postgres,
573566
"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. } ]},
574567
"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. } ]},
575568
));
576569

577-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
578570
test_type!(polygon<sqlx::postgres::types::PgPolygon>(Postgres,
579571
"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![
580572
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,
583575
]},
584576
));
585577

586-
#[cfg(any(postgres_12, postgres_13, postgres_14, postgres_15))]
587578
test_type!(circle<sqlx::postgres::types::PgCircle>(Postgres,
588579
"circle('<(1.1, -2.2), 3.3>')" ~= sqlx::postgres::types::PgCircle { x: 1.1, y:-2.2, radius: 3.3 },
589580
"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,
678669
],
679670
));
680671

681-
// FIXME: needed to disable `ltree` tests in version that don't have a binary format for it
682-
// but `PgLTree` should just fall back to text format
683-
#[cfg(any(postgres_14, postgres_15))]
684672
test_type!(ltree<sqlx::postgres::types::PgLTree>(Postgres,
685673
"'Foo.Bar.Baz.Quux'::ltree" == sqlx::postgres::types::PgLTree::from_str("Foo.Bar.Baz.Quux").unwrap(),
686674
"'Alpha.Beta.Delta.Gamma'::ltree" == sqlx::postgres::types::PgLTree::try_from_iter(["Alpha", "Beta", "Delta", "Gamma"]).unwrap(),
687675
));
688676

689-
// FIXME: needed to disable `ltree` tests in version that don't have a binary format for it
690-
// but `PgLTree` should just fall back to text format
691-
#[cfg(any(postgres_14, postgres_15))]
692677
test_type!(ltree_vec<Vec<sqlx::postgres::types::PgLTree>>(Postgres,
693678
"array['Foo.Bar.Baz.Quux', 'Alpha.Beta.Delta.Gamma']::ltree[]" ==
694679
vec![

0 commit comments

Comments
 (0)