Skip to content

Commit a4e5639

Browse files
authored
Merge pull request #46 from digital-society-coop/sqlx08
Upgrade to sqlx 0.8
2 parents 28db0ca + ceaeda3 commit a4e5639

File tree

4 files changed

+16
-42
lines changed

4 files changed

+16
-42
lines changed

.github/workflows/pr.yaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,7 @@ on:
77

88
jobs:
99
clippy:
10-
strategy:
11-
fail-fast: false
12-
matrix:
13-
db: ['', all-databases, mysql, postgres, sqlite]
14-
db_any: ['', any]
15-
runtime: [runtime-tokio-native-tls, runtime-tokio-rustls]
16-
exclude:
17-
# no-db w/ any doesn't make sense (sqlx won't compile)
18-
- db: ''
19-
db_any: any
20-
# all-databases w/ any is redundant (all-databases enables any)
21-
- db: all-databases
22-
db_any: any
23-
name: clippy (${{ matrix.runtime }}, ${{ matrix.db || 'no-db' }} ${{ matrix.db_any && 'w/ any' || 'w/o any' }})
10+
name: clippy
2411
runs-on: ubuntu-latest
2512
steps:
2613
- uses: actions/checkout@v2
@@ -32,7 +19,7 @@ jobs:
3219
- uses: actions-rs/cargo@v1
3320
with:
3421
command: clippy
35-
args: --features '${{ matrix.db }} ${{ matrix.db_any }} ${{ matrix.runtime }}' -- -D warnings
22+
args: -- -D warnings
3623

3724
doc:
3825
runs-on: ubuntu-latest
@@ -45,7 +32,6 @@ jobs:
4532
- uses: actions-rs/cargo@v1
4633
with:
4734
command: doc
48-
args: --features runtime-tokio-rustls,all-databases
4935

5036
fmt:
5137
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "axum-sqlx-tx"
33
description = "Request-scoped SQLx transactions for axum"
4-
version = "0.8.0"
4+
version = "0.9.0"
55
license = "MIT"
66
repository = "https://github.com/digital-society-coop/axum-sqlx-tx/"
77
edition = "2021"
@@ -12,34 +12,21 @@ include = [
1212
"**/*.rs"
1313
]
1414

15-
[features]
16-
all-databases = ["any", "mysql", "postgres", "sqlite"]
17-
any = ["sqlx/any"]
18-
mysql = ["sqlx/mysql"]
19-
postgres = ["sqlx/postgres"]
20-
sqlite = ["sqlx/sqlite"]
21-
22-
runtime-tokio-native-tls = ["sqlx/runtime-tokio-native-tls"]
23-
runtime-tokio-rustls = ["sqlx/runtime-tokio-rustls"]
24-
25-
[package.metadata.docs.rs]
26-
features = ["all-databases", "runtime-tokio-rustls"]
27-
2815
[dependencies]
2916
axum-core = "0.4"
3017
bytes = "1"
3118
futures-core = "0.3"
3219
http = "1"
3320
http-body = "1"
3421
parking_lot = { version = "0.12", features = ["arc_lock", "send_guard"] }
35-
sqlx = { version = "0.7", default-features = false }
22+
sqlx = { version = "0.8", default-features = false }
3623
thiserror = "1"
3724
tower-layer = "0.3"
3825
tower-service = "0.3"
3926

4027
[dev-dependencies]
41-
axum-sqlx-tx = { path = ".", features = ["runtime-tokio-rustls", "sqlite"] }
4228
axum = "0.7.2"
4329
hyper = "1.0.1"
30+
sqlx = { version = "0.8", features = ["runtime-tokio", "sqlite"] }
4431
tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] }
4532
tower = "0.4.12"

src/tx.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,7 @@ where
232232
self,
233233
sql: &'q str,
234234
parameters: &'e [<Self::Database as sqlx::Database>::TypeInfo],
235-
) -> BoxFuture<
236-
'e,
237-
Result<<Self::Database as sqlx::database::HasStatement<'q>>::Statement, sqlx::Error>,
238-
>
235+
) -> BoxFuture<'e, Result<<Self::Database as sqlx::Database>::Statement<'q>, sqlx::Error>>
239236
where
240237
'c: 'e,
241238
{

tests/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ async fn multi_db() {
427427

428428
async fn insert_user(tx: &mut Tx, id: i32, name: &str) -> (i32, String) {
429429
let mut args = SqliteArguments::default();
430-
args.add(id);
431-
args.add(name);
430+
args.add(id).unwrap();
431+
args.add(name).unwrap();
432432
sqlx::query_as_with(
433433
r#"INSERT INTO users VALUES (?, ?) RETURNING id, name;"#,
434434
args,
@@ -486,11 +486,13 @@ where
486486
(pool, Response { status, body })
487487
}
488488

489-
struct MyExtractorError(axum_sqlx_tx::Error);
489+
struct MyExtractorError {
490+
_0: axum_sqlx_tx::Error,
491+
}
490492

491493
impl From<axum_sqlx_tx::Error> for MyExtractorError {
492494
fn from(error: axum_sqlx_tx::Error) -> Self {
493-
Self(error)
495+
Self { _0: error }
494496
}
495497
}
496498

@@ -500,11 +502,13 @@ impl IntoResponse for MyExtractorError {
500502
}
501503
}
502504

503-
struct MyLayerError(sqlx::Error);
505+
struct MyLayerError {
506+
_0: sqlx::Error,
507+
}
504508

505509
impl From<sqlx::Error> for MyLayerError {
506510
fn from(error: sqlx::Error) -> Self {
507-
Self(error)
511+
Self { _0: error }
508512
}
509513
}
510514

0 commit comments

Comments
 (0)