Skip to content

Commit 4e95baf

Browse files
committed
Merge remote-tracking branch 'origin/main' into sqlx-toml
# Conflicts: # .github/workflows/examples.yml # sqlx-postgres/src/connection/mod.rs
2 parents 8ddcd06 + 1c9cbe9 commit 4e95baf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2465
-187
lines changed

.github/workflows/examples.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616

17-
- name: Use latest Rust
18-
run: rustup override set stable
17+
- name: Setup Rust
18+
run: |
19+
rustup show active-toolchain || rustup toolchain install
20+
rustup override set stable
1921
2022
- uses: Swatinem/rust-cache@v2
21-
with:
22-
key: sqlx-cli
2323

2424
- run: >
2525
cargo build
@@ -63,9 +63,10 @@ jobs:
6363
6464
- uses: actions/checkout@v4
6565

66+
- name: Setup Rust
67+
run: rustup show active-toolchain || rustup toolchain install
68+
6669
- uses: Swatinem/rust-cache@v2
67-
with:
68-
key: mysql-examples
6970

7071
- name: Todos (Setup)
7172
working-directory: examples/mysql/todos
@@ -106,9 +107,8 @@ jobs:
106107
107108
- uses: actions/checkout@v4
108109

109-
- uses: Swatinem/rust-cache@v2
110-
with:
111-
key: pg-examples
110+
- name: Setup Rust
111+
run: rustup show active-toolchain || rustup toolchain install
112112

113113
- name: Axum Social with Tests (Setup)
114114
working-directory: examples/postgres/axum-social-with-tests
@@ -231,9 +231,10 @@ jobs:
231231
232232
- uses: actions/checkout@v4
233233

234+
- name: Setup Rust
235+
run: rustup show active-toolchain || rustup toolchain install
236+
234237
- uses: Swatinem/rust-cache@v2
235-
with:
236-
key: sqlite-examples
237238

238239
- name: TODOs (Setup)
239240
env:

.github/workflows/sqlx-cli.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717

18-
- run: |
19-
rustup update
18+
- name: Setup Rust
19+
run: |
20+
rustup show active-toolchain || rustup toolchain install
2021
rustup component add clippy
2122
rustup toolchain install beta
2223
rustup component add --toolchain beta clippy
@@ -40,18 +41,19 @@ jobs:
4041
matrix:
4142
# Note: macOS-latest uses M1 Silicon (ARM64)
4243
os:
43-
- ubuntu-latest
44-
# FIXME: migrations tests fail on Windows for whatever reason
45-
# - windows-latest
46-
- macOS-13
47-
- macOS-latest
44+
- ubuntu-latest
45+
# FIXME: migrations tests fail on Windows for whatever reason
46+
# - windows-latest
47+
- macOS-13
48+
- macOS-latest
4849

4950
steps:
5051
- uses: actions/checkout@v4
5152

53+
- name: Setup Rust
54+
run: rustup show active-toolchain || rustup toolchain install
55+
5256
- uses: Swatinem/rust-cache@v2
53-
with:
54-
key: ${{ runner.os }}-test
5557

5658
- run: cargo test --manifest-path sqlx-cli/Cargo.toml
5759

@@ -85,12 +87,12 @@ jobs:
8587
steps:
8688
- uses: actions/checkout@v4
8789

88-
- name: Use latest Rust
89-
run: rustup override set stable
90+
- name: Setup Rust
91+
run: |
92+
rustup show active-toolchain || rustup toolchain install
93+
rustup override set stable
9094
9195
- uses: Swatinem/rust-cache@v2
92-
with:
93-
key: ${{ runner.os }}-cli
9496

9597
- run: cargo build --manifest-path sqlx-cli/Cargo.toml --bin cargo-sqlx ${{ matrix.args }}
9698

.github/workflows/sqlx.yml

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,33 @@ on:
1010
jobs:
1111
format:
1212
name: Format
13-
runs-on: ubuntu-22.04
13+
runs-on: ubuntu-24.04
1414
steps:
1515
- uses: actions/checkout@v4
1616
- run: rustup component add rustfmt
1717
- run: cargo fmt --all -- --check
1818

1919
check:
2020
name: Check
21-
runs-on: ubuntu-22.04
21+
runs-on: ubuntu-24.04
2222
strategy:
2323
matrix:
24-
runtime: [async-std, tokio]
25-
tls: [native-tls, rustls, none]
24+
runtime: [ async-std, tokio ]
25+
tls: [ native-tls, rustls, none ]
2626
steps:
2727
- uses: actions/checkout@v4
2828

29-
- uses: Swatinem/rust-cache@v2
30-
with:
31-
key: "${{ runner.os }}-check-${{ matrix.runtime }}-${{ matrix.tls }}"
32-
33-
- run: |
34-
rustup update
29+
# Swatinem/rust-cache recommends setting up the rust toolchain first because it's used in cache keys
30+
- name: Setup Rust
31+
# https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html
32+
run: |
33+
rustup show active-toolchain || rustup toolchain install
3534
rustup component add clippy
3635
rustup toolchain install beta
3736
rustup component add --toolchain beta clippy
3837
38+
- uses: Swatinem/rust-cache@v2
39+
3940
- run: >
4041
cargo clippy
4142
--no-default-features
@@ -52,26 +53,27 @@ jobs:
5253
5354
check-minimal-versions:
5455
name: Check build using minimal versions
55-
runs-on: ubuntu-22.04
56+
runs-on: ubuntu-24.04
5657
steps:
5758
- uses: actions/checkout@v4
58-
- run: rustup update
59-
- run: rustup toolchain install nightly
59+
- name: Setup Rust
60+
run: |
61+
rustup show active-toolchain || rustup toolchain install
62+
rustup toolchain install nightly
6063
- run: cargo +nightly generate-lockfile -Z minimal-versions
6164
- run: cargo build --all-features
6265

6366
test:
6467
name: Unit Tests
65-
runs-on: ubuntu-22.04
68+
runs-on: ubuntu-24.04
6669
steps:
6770
- uses: actions/checkout@v4
6871

69-
- uses: Swatinem/rust-cache@v2
70-
with:
71-
key: ${{ runner.os }}-test
72+
# https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html
73+
- name: Setup Rust
74+
run: rustup show active-toolchain || rustup toolchain install
7275

73-
- name: Install Rust
74-
run: rustup update
76+
- uses: Swatinem/rust-cache@v2
7577

7678
- name: Test sqlx-core
7779
run: >
@@ -113,20 +115,22 @@ jobs:
113115
114116
sqlite:
115117
name: SQLite
116-
runs-on: ubuntu-22.04
118+
runs-on: ubuntu-24.04
117119
strategy:
118120
matrix:
119-
runtime: [async-std, tokio]
120-
linking: [sqlite, sqlite-unbundled]
121+
runtime: [ async-std, tokio ]
122+
linking: [ sqlite, sqlite-unbundled ]
121123
needs: check
122124
steps:
123125
- uses: actions/checkout@v4
124126

125127
- run: mkdir /tmp/sqlite3-lib && wget -O /tmp/sqlite3-lib/ipaddr.so https://github.com/nalgeon/sqlean/releases/download/0.15.2/ipaddr.so
126128

129+
# https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html
130+
- name: Setup Rust
131+
run: rustup show active-toolchain || rustup toolchain install
132+
127133
- uses: Swatinem/rust-cache@v2
128-
with:
129-
key: "${{ runner.os }}-${{ matrix.linking }}-${{ matrix.runtime }}-${{ matrix.tls }}"
130134

131135
- name: Install system sqlite library
132136
if: ${{ matrix.linking == 'sqlite-unbundled' }}
@@ -179,19 +183,20 @@ jobs:
179183
180184
postgres:
181185
name: Postgres
182-
runs-on: ubuntu-22.04
186+
runs-on: ubuntu-24.04
183187
strategy:
184188
matrix:
185-
postgres: [17, 13]
186-
runtime: [async-std, tokio]
187-
tls: [native-tls, rustls-aws-lc-rs, rustls-ring, none]
189+
postgres: [ 17, 13 ]
190+
runtime: [ async-std, tokio ]
191+
tls: [ native-tls, rustls-aws-lc-rs, rustls-ring, none ]
188192
needs: check
189193
steps:
190194
- uses: actions/checkout@v4
191195

196+
- name: Setup Rust
197+
run: rustup show active-toolchain || rustup toolchain install
198+
192199
- uses: Swatinem/rust-cache@v2
193-
with:
194-
key: "${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}"
195200

196201
- env:
197202
# FIXME: needed to disable `ltree` tests in Postgres 9.6
@@ -279,19 +284,20 @@ jobs:
279284

280285
mysql:
281286
name: MySQL
282-
runs-on: ubuntu-22.04
287+
runs-on: ubuntu-24.04
283288
strategy:
284289
matrix:
285-
mysql: [8]
286-
runtime: [async-std, tokio]
287-
tls: [native-tls, rustls-aws-lc-rs, rustls-ring, none]
290+
mysql: [ 8 ]
291+
runtime: [ async-std, tokio ]
292+
tls: [ native-tls, rustls-aws-lc-rs, rustls-ring, none ]
288293
needs: check
289294
steps:
290295
- uses: actions/checkout@v4
291296

297+
- name: Setup Rust
298+
run: rustup show active-toolchain || rustup toolchain install
299+
292300
- uses: Swatinem/rust-cache@v2
293-
with:
294-
key: "${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}"
295301

296302
- run: cargo build --features mysql,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
297303

@@ -367,19 +373,20 @@ jobs:
367373

368374
mariadb:
369375
name: MariaDB
370-
runs-on: ubuntu-22.04
376+
runs-on: ubuntu-24.04
371377
strategy:
372378
matrix:
373-
mariadb: [verylatest, 11_4, 10_11, 10_4]
374-
runtime: [async-std, tokio]
375-
tls: [native-tls, rustls-aws-lc-rs, rustls-ring, none]
379+
mariadb: [ verylatest, 11_4, 10_11, 10_4 ]
380+
runtime: [ async-std, tokio ]
381+
tls: [ native-tls, rustls-aws-lc-rs, rustls-ring, none ]
376382
needs: check
377383
steps:
378384
- uses: actions/checkout@v4
379385

386+
- name: Setup Rust
387+
run: rustup show active-toolchain || rustup toolchain install
388+
380389
- uses: Swatinem/rust-cache@v2
381-
with:
382-
key: "${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}"
383390

384391
- run: cargo build --features mysql,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
385392

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ _unstable-all-types = [
7272
"json",
7373
"time",
7474
"chrono",
75+
"ipnet",
7576
"ipnetwork",
7677
"mac_address",
7778
"uuid",
@@ -123,6 +124,7 @@ json = ["sqlx-macros?/json", "sqlx-mysql?/json", "sqlx-postgres?/json", "sqlx-sq
123124
bigdecimal = ["sqlx-core/bigdecimal", "sqlx-macros?/bigdecimal", "sqlx-mysql?/bigdecimal", "sqlx-postgres?/bigdecimal"]
124125
bit-vec = ["sqlx-core/bit-vec", "sqlx-macros?/bit-vec", "sqlx-postgres?/bit-vec"]
125126
chrono = ["sqlx-core/chrono", "sqlx-macros?/chrono", "sqlx-mysql?/chrono", "sqlx-postgres?/chrono", "sqlx-sqlite?/chrono"]
127+
ipnet = ["sqlx-core/ipnet", "sqlx-macros?/ipnet", "sqlx-postgres?/ipnet"]
126128
ipnetwork = ["sqlx-core/ipnetwork", "sqlx-macros?/ipnetwork", "sqlx-postgres?/ipnetwork"]
127129
mac_address = ["sqlx-core/mac_address", "sqlx-macros?/mac_address", "sqlx-postgres?/mac_address"]
128130
rust_decimal = ["sqlx-core/rust_decimal", "sqlx-macros?/rust_decimal", "sqlx-mysql?/rust_decimal", "sqlx-postgres?/rust_decimal"]
@@ -150,6 +152,7 @@ sqlx = { version = "=0.8.3", path = ".", default-features = false }
150152
bigdecimal = "0.4.0"
151153
bit-vec = "0.6.3"
152154
chrono = { version = "0.4.34", default-features = false, features = ["std", "clock"] }
155+
ipnet = "2.3.0"
153156
ipnetwork = "0.20.0"
154157
mac_address = "1.1.5"
155158
rust_decimal = { version = "1.26.1", default-features = false, features = ["std"] }
@@ -195,6 +198,7 @@ rand_xoshiro = "0.6.0"
195198
hex = "0.4.3"
196199
tempfile = "3.10.1"
197200
criterion = { version = "0.5.1", features = ["async_tokio"] }
201+
libsqlite3-sys = { version = "0.30.1" }
198202

199203
# If this is an unconditional dev-dependency then Cargo will *always* try to build `libsqlite3-sys`,
200204
# even when SQLite isn't the intended test target, and fail if the build environment is not set up for compiling C code.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ be removed in the future.
220220

221221
- `rust_decimal`: Add support for `NUMERIC` using the `rust_decimal` crate.
222222

223+
- `ipnet`: Add support for `INET` and `CIDR` (in postgres) using the `ipnet` crate.
224+
223225
- `ipnetwork`: Add support for `INET` and `CIDR` (in postgres) using the `ipnetwork` crate.
224226

225227
- `json`: Add support for `JSON` and `JSONB` (in postgres) using the `serde_json` crate.

ci.db

-36 KB
Binary file not shown.

sqlx-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ bit-vec = { workspace = true, optional = true }
5656
bigdecimal = { workspace = true, optional = true }
5757
rust_decimal = { workspace = true, optional = true }
5858
time = { workspace = true, optional = true }
59+
ipnet = { workspace = true, optional = true }
5960
ipnetwork = { workspace = true, optional = true }
6061
mac_address = { workspace = true, optional = true }
6162
uuid = { workspace = true, optional = true }

sqlx-core/src/acquire.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<'a, DB: Database> Acquire<'a> for &'_ Pool<DB> {
9393
let conn = self.acquire();
9494

9595
Box::pin(async move {
96-
Transaction::begin(MaybePoolConnection::PoolConnection(conn.await?)).await
96+
Transaction::begin(MaybePoolConnection::PoolConnection(conn.await?), None).await
9797
})
9898
}
9999
}
@@ -121,7 +121,7 @@ macro_rules! impl_acquire {
121121
'c,
122122
Result<$crate::transaction::Transaction<'c, $DB>, $crate::error::Error>,
123123
> {
124-
$crate::transaction::Transaction::begin(self)
124+
$crate::transaction::Transaction::begin(self, None)
125125
}
126126
}
127127
};

0 commit comments

Comments
 (0)