Skip to content

Commit 02ab378

Browse files
authored
Upgrade to SQLx v0.7 (#652)
* Upgrade to SQLx v0.7 * Upgrade ipnetwork to v0.20 * Encode chrono types in Any driver as string * Temporary enable `sqlx/bigdecimal` feature when `with-rust_decimal` is enabled (launchbadge/sqlx#2549) * Fixup * Fixup * Fixup * CI * Fixup * Revert "Temporary enable `sqlx/bigdecimal` feature when `with-rust_decimal` is enabled (launchbadge/sqlx#2549)" This reverts commit fa50aa2. * CI fmt checks * Bump `sea-query-binder` to v0.5.0 * Refactor
1 parent b7e5413 commit 02ab378

File tree

12 files changed

+73
-56
lines changed

12 files changed

+73
-56
lines changed

.github/workflows/rust.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ jobs:
3333
with:
3434
toolchain: nightly
3535
components: rustfmt
36-
- run: cargo fmt --all -- --check
36+
- run: cargo fmt --manifest-path Cargo.toml --all -- --check
37+
- run: cargo fmt --manifest-path sea-query-attr/Cargo.toml --all -- --check
3738
- run: cargo fmt --manifest-path sea-query-binder/Cargo.toml --all -- --check
38-
- run: cargo fmt --manifest-path sea-query-rusqlite/Cargo.toml --all -- --check
39+
- run: cargo fmt --manifest-path sea-query-derive/Cargo.toml --all -- --check
3940
- run: cargo fmt --manifest-path sea-query-postgres/Cargo.toml --all -- --check
41+
- run: cargo fmt --manifest-path sea-query-rusqlite/Cargo.toml --all -- --check
42+
- run: cargo fmt --manifest-path examples/sqlx_sqlite/Cargo.toml --all -- --check
43+
- run: cargo fmt --manifest-path examples/sqlx_any/Cargo.toml --all -- --check
44+
- run: cargo fmt --manifest-path examples/rusqlite/Cargo.toml --all -- --check
45+
- run: cargo fmt --manifest-path examples/sqlx_postgres/Cargo.toml --all -- --check
46+
- run: cargo fmt --manifest-path examples/postgres/Cargo.toml --all -- --check
47+
- run: cargo fmt --manifest-path examples/sqlx_mysql/Cargo.toml --all -- --check
4048

4149
clippy:
4250
name: Clippy
@@ -247,3 +255,12 @@ jobs:
247255
- uses: dtolnay/rust-toolchain@stable
248256
- run: cargo build --manifest-path examples/${{ matrix.example }}/Cargo.toml
249257
- run: cargo run --manifest-path examples/${{ matrix.example }}/Cargo.toml
258+
259+
any:
260+
name: Any
261+
runs-on: ubuntu-latest
262+
needs: ["test", "derive-test", "binder-build"]
263+
steps:
264+
- uses: actions/checkout@v3
265+
- uses: dtolnay/rust-toolchain@stable
266+
- run: cargo build --manifest-path examples/sqlx_any/Cargo.toml

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ uuid = { version = "1", default-features = false, optional = true }
4141
proc-macro2 = { version = "1", default-features = false, optional = true }
4242
quote = { version = "1", default-features = false, optional = true }
4343
time = { version = "0.3", default-features = false, optional = true, features = ["macros", "formatting"] }
44-
ipnetwork = { version = "0.19", default-features = false, optional = true }
44+
ipnetwork = { version = "0.20", default-features = false, optional = true }
4545
mac_address = { version = "1.1", default-features = false, optional = true }
4646
ordered-float = { version = "3.4", default-features = false, optional = true }
4747

examples/sqlx_any/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ serde_json = "1"
1414
rust_decimal = { version = "1" }
1515
bigdecimal = { version = "0.3" }
1616
async-std = { version = "1.8", features = [ "attributes" ] }
17-
sqlx = "0.6"
17+
sqlx = "0.7"
1818
sea-query = { path = "../../" }
1919
sea-query-binder = { path = "../../sea-query-binder", features = [
2020
"sqlx-postgres",

examples/sqlx_any/src/main.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use chrono::{NaiveDate, NaiveDateTime};
1+
use chrono::NaiveDate;
22
use sea_query::{
33
ColumnDef, Expr, Func, Iden, MysqlQueryBuilder, OnConflict, Order, PostgresQueryBuilder, Query,
44
QueryBuilder, SchemaBuilder, SqliteQueryBuilder, Table,
@@ -65,7 +65,7 @@ async fn main() {
6565
.col(ColumnDef::new(Character::Created).date_time())
6666
.build_any(schema_builder);
6767

68-
let result = sqlx::query(&sql).execute(&mut pool).await;
68+
let result = sqlx::query(&sql).execute(&mut *pool).await;
6969
println!("Create table character: {result:?}\n");
7070

7171
// Create
@@ -90,7 +90,7 @@ async fn main() {
9090
.build_any_sqlx(query_builder);
9191

9292
let row = sqlx::query_with(&sql, values)
93-
.fetch_one(&mut pool)
93+
.fetch_one(&mut *pool)
9494
.await
9595
.unwrap();
9696
let id: i32 = row.try_get(0).unwrap();
@@ -111,7 +111,7 @@ async fn main() {
111111
.build_any_sqlx(query_builder);
112112

113113
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values)
114-
.fetch_all(&mut pool)
114+
.fetch_all(&mut *pool)
115115
.await
116116
.unwrap();
117117
println!("Select one from character:");
@@ -128,7 +128,7 @@ async fn main() {
128128
.and_where(Expr::col(Character::Id).eq(id))
129129
.build_any_sqlx(query_builder);
130130

131-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
131+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
132132
println!("Update character: {result:?}\n");
133133

134134
// Read
@@ -146,7 +146,7 @@ async fn main() {
146146
.build_any_sqlx(query_builder);
147147

148148
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values)
149-
.fetch_all(&mut pool)
149+
.fetch_all(&mut *pool)
150150
.await
151151
.unwrap();
152152
println!("Select one from character:");
@@ -163,7 +163,7 @@ async fn main() {
163163
.build_any_sqlx(query_builder);
164164

165165
let row = sqlx::query_with(&sql, values)
166-
.fetch_one(&mut pool)
166+
.fetch_one(&mut *pool)
167167
.await
168168
.unwrap();
169169
print!("Count character: ");
@@ -184,7 +184,7 @@ async fn main() {
184184
)
185185
.build_any_sqlx(query_builder);
186186

187-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
187+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
188188
println!("Insert into character (with upsert): {result:?}\n");
189189

190190
// Read
@@ -201,7 +201,7 @@ async fn main() {
201201
.build_any_sqlx(query_builder);
202202

203203
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values)
204-
.fetch_all(&mut pool)
204+
.fetch_all(&mut *pool)
205205
.await
206206
.unwrap();
207207
println!("Select all characters:");
@@ -217,7 +217,7 @@ async fn main() {
217217
.and_where(Expr::col(Character::Id).eq(id))
218218
.build_any_sqlx(query_builder);
219219

220-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
220+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
221221
println!("Delete character: {result:?}");
222222
}
223223

@@ -236,5 +236,5 @@ struct CharacterStructChrono {
236236
id: i32,
237237
character: String,
238238
font_size: i32,
239-
created: NaiveDateTime,
239+
created: String,
240240
}

examples/sqlx_mysql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ serde_json = "1"
1414
rust_decimal = { version = "1" }
1515
bigdecimal = { version = "0.3" }
1616
async-std = { version = "1.8", features = [ "attributes" ] }
17-
sqlx = "0.6"
17+
sqlx = "0.7"
1818
sea-query = { path = "../../" }
1919
sea-query-binder = { path = "../../sea-query-binder", features = [
2020
"sqlx-mysql",

examples/sqlx_mysql/src/main.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async fn main() {
4040
.col(ColumnDef::new(Character::Created).date_time())
4141
.build(MysqlQueryBuilder);
4242

43-
let result = sqlx::query(&sql).execute(&mut pool).await;
43+
let result = sqlx::query(&sql).execute(&mut *pool).await;
4444
println!("Create table character: {result:?}\n");
4545

4646
// Create
@@ -92,7 +92,7 @@ async fn main() {
9292
])
9393
.build_sqlx(MysqlQueryBuilder);
9494

95-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
95+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
9696
println!("Insert into character: {result:?}\n");
9797
let id = result.unwrap().last_insert_id();
9898

@@ -115,7 +115,7 @@ async fn main() {
115115
.build_sqlx(MysqlQueryBuilder);
116116

117117
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone())
118-
.fetch_all(&mut pool)
118+
.fetch_all(&mut *pool)
119119
.await
120120
.unwrap();
121121
println!("Select one from character:");
@@ -125,7 +125,7 @@ async fn main() {
125125
println!();
126126

127127
let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values)
128-
.fetch_all(&mut pool)
128+
.fetch_all(&mut *pool)
129129
.await
130130
.unwrap();
131131
println!("Select one from character:");
@@ -142,7 +142,7 @@ async fn main() {
142142
.and_where(Expr::col(Character::Id).eq(id))
143143
.build_sqlx(MysqlQueryBuilder);
144144

145-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
145+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
146146
println!("Update character: {result:?}\n");
147147

148148
// Read
@@ -164,7 +164,7 @@ async fn main() {
164164
.build_sqlx(MysqlQueryBuilder);
165165

166166
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone())
167-
.fetch_all(&mut pool)
167+
.fetch_all(&mut *pool)
168168
.await
169169
.unwrap();
170170
println!("Select one from character:");
@@ -174,7 +174,7 @@ async fn main() {
174174
println!();
175175

176176
let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values)
177-
.fetch_all(&mut pool)
177+
.fetch_all(&mut *pool)
178178
.await
179179
.unwrap();
180180
println!("Select one from character:");
@@ -197,7 +197,7 @@ async fn main() {
197197
)
198198
.build_sqlx(MysqlQueryBuilder);
199199

200-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
200+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
201201
println!("Insert into character (with upsert): {result:?}\n");
202202
let id = result.unwrap().last_insert_id();
203203

@@ -219,7 +219,7 @@ async fn main() {
219219
.build_sqlx(MysqlQueryBuilder);
220220

221221
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone())
222-
.fetch_all(&mut pool)
222+
.fetch_all(&mut *pool)
223223
.await
224224
.unwrap();
225225
println!("Select all characters:");
@@ -229,7 +229,7 @@ async fn main() {
229229
println!();
230230

231231
let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values)
232-
.fetch_all(&mut pool)
232+
.fetch_all(&mut *pool)
233233
.await
234234
.unwrap();
235235
println!("Select all characters:");
@@ -246,7 +246,7 @@ async fn main() {
246246
.build_sqlx(MysqlQueryBuilder);
247247

248248
let row = sqlx::query_with(&sql, values)
249-
.fetch_one(&mut pool)
249+
.fetch_one(&mut *pool)
250250
.await
251251
.unwrap();
252252
print!("Count character: ");
@@ -261,7 +261,7 @@ async fn main() {
261261
.and_where(Expr::col(Character::Id).eq(id))
262262
.build_sqlx(MysqlQueryBuilder);
263263

264-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
264+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
265265
println!("Delete character: {result:?}");
266266
}
267267

examples/sqlx_postgres/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ uuid = { version = "1", features = ["serde", "v4"] }
1313
serde_json = "1"
1414
rust_decimal = { version = "1" }
1515
bigdecimal = { version = "0.3" }
16-
ipnetwork = { version = "0.19" }
16+
ipnetwork = { version = "0.20" }
1717
mac_address = { version = "1.1" }
1818
async-std = { version = "1.8", features = [ "attributes" ] }
19-
sqlx = "0.6"
19+
sqlx = "0.7"
2020
sea-query = { path = "../../" }
2121
sea-query-binder = { path = "../../sea-query-binder", features = [
2222
"sqlx-postgres",

examples/sqlx_postgres/src/main.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async fn main() {
4747
.col(ColumnDef::new(Character::MacAddress).mac_address())
4848
.build(PostgresQueryBuilder);
4949

50-
let result = sqlx::query(&sql).execute(&mut pool).await;
50+
let result = sqlx::query(&sql).execute(&mut *pool).await;
5151
println!("Create table character: {result:?}\n");
5252

5353
// Create
@@ -111,7 +111,7 @@ async fn main() {
111111
.build_sqlx(PostgresQueryBuilder);
112112

113113
let row = sqlx::query_with(&sql, values)
114-
.fetch_one(&mut pool)
114+
.fetch_one(&mut *pool)
115115
.await
116116
.unwrap();
117117
let id: i32 = row.try_get(0).unwrap();
@@ -138,7 +138,7 @@ async fn main() {
138138
.build_sqlx(PostgresQueryBuilder);
139139

140140
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone())
141-
.fetch_all(&mut pool)
141+
.fetch_all(&mut *pool)
142142
.await
143143
.unwrap();
144144
println!("Select one from character:");
@@ -148,7 +148,7 @@ async fn main() {
148148
println!();
149149

150150
let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values)
151-
.fetch_all(&mut pool)
151+
.fetch_all(&mut *pool)
152152
.await
153153
.unwrap();
154154
println!("Select one from character:");
@@ -165,7 +165,7 @@ async fn main() {
165165
.and_where(Expr::col(Character::Id).eq(id))
166166
.build_sqlx(PostgresQueryBuilder);
167167

168-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
168+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
169169
println!("Update character: {result:?}\n");
170170

171171
// Read
@@ -189,7 +189,7 @@ async fn main() {
189189
.build_sqlx(PostgresQueryBuilder);
190190

191191
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone())
192-
.fetch_all(&mut pool)
192+
.fetch_all(&mut *pool)
193193
.await
194194
.unwrap();
195195
println!("Select one from character:");
@@ -199,7 +199,7 @@ async fn main() {
199199
println!();
200200

201201
let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values)
202-
.fetch_all(&mut pool)
202+
.fetch_all(&mut *pool)
203203
.await
204204
.unwrap();
205205
println!("Select one from character:");
@@ -216,7 +216,7 @@ async fn main() {
216216
.build_sqlx(PostgresQueryBuilder);
217217

218218
let row = sqlx::query_with(&sql, values)
219-
.fetch_one(&mut pool)
219+
.fetch_one(&mut *pool)
220220
.await
221221
.unwrap();
222222
print!("Count character: ");
@@ -238,7 +238,7 @@ async fn main() {
238238
)
239239
.build_sqlx(PostgresQueryBuilder);
240240

241-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
241+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
242242
println!("Insert into character (with upsert): {result:?}\n");
243243

244244
// Read
@@ -261,7 +261,7 @@ async fn main() {
261261
.build_sqlx(PostgresQueryBuilder);
262262

263263
let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone())
264-
.fetch_all(&mut pool)
264+
.fetch_all(&mut *pool)
265265
.await
266266
.unwrap();
267267
println!("Select all characters:");
@@ -271,7 +271,7 @@ async fn main() {
271271
println!();
272272

273273
let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values)
274-
.fetch_all(&mut pool)
274+
.fetch_all(&mut *pool)
275275
.await
276276
.unwrap();
277277
println!("Select all characters:");
@@ -287,7 +287,7 @@ async fn main() {
287287
.and_where(Expr::col(Character::Id).eq(id))
288288
.build_sqlx(PostgresQueryBuilder);
289289

290-
let result = sqlx::query_with(&sql, values).execute(&mut pool).await;
290+
let result = sqlx::query_with(&sql, values).execute(&mut *pool).await;
291291
println!("Delete character: {result:?}");
292292
}
293293

examples/sqlx_sqlite/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ time = { version = "0.3", features = ["macros"] }
1212
uuid = { version = "1", features = ["serde", "v4"] }
1313
serde_json = "1"
1414
async-std = { version = "1.8", features = [ "attributes" ] }
15-
sqlx = "0.6.1"
15+
sqlx = "0.7"
1616
sea-query = { path = "../../" }
1717
sea-query-binder = { path = "../../sea-query-binder", features = [
1818
"sqlx-sqlite",

0 commit comments

Comments
 (0)