Skip to content

Commit 0679df9

Browse files
authored
Bump SQLx to 0.8 (#136)
* Bump SQLx to 0.8 * Bump sea-query * Fix clippy warnings * Blocking Issues: upgrade to SQLx 0.8 on hold, just testing a workaround, not an ideal fix (launchbadge/sqlx#3387) * GetMySqlValue * Bump sea-query
1 parent b650684 commit 0679df9

File tree

16 files changed

+63
-44
lines changed

16 files changed

+63
-44
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ path = "src/lib.rs"
3636
[dependencies]
3737
futures = { version = "0.3", default-features = false, optional = true, features = ["alloc"] }
3838
sea-schema-derive = { version = "0.3.0", path = "sea-schema-derive", default-features = false }
39-
sea-query = { version = "0.31.0", default-features = false, features = ["derive"] }
40-
sea-query-binder = { version = "0.6.0", default-features = false, optional = true }
39+
sea-query = { version = "0.32.0-rc.1", default-features = false, features = ["derive"] }
40+
sea-query-binder = { version = "0.7.0-rc.1", default-features = false, optional = true }
4141
serde = { version = "1", default-features = false, optional = true, features = ["derive"] }
42-
sqlx = { version = "0.7", default-features = false, optional = true }
42+
sqlx = { version = "0.8", default-features = false, optional = true }
4343
log = { version = "0.4", default-features = false, optional = true }
4444

4545
[features]

src/mysql/discovery/executor/real.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use sea_query::{MysqlQueryBuilder, SelectStatement};
22
use sea_query_binder::SqlxBinder;
3-
use sqlx::{mysql::MySqlRow, MySqlPool};
3+
use sqlx::{mysql::MySqlRow, MySqlPool, Row};
44

55
use crate::{debug_print, sqlx_types::SqlxError};
66

@@ -28,3 +28,20 @@ impl Executor {
2828
.await
2929
}
3030
}
31+
32+
pub trait GetMySqlValue {
33+
fn get_string(&self, idx: usize) -> String;
34+
35+
fn get_string_opt(&self, idx: usize) -> Option<String>;
36+
}
37+
38+
impl GetMySqlValue for MySqlRow {
39+
fn get_string(&self, idx: usize) -> String {
40+
String::from_utf8(self.get::<Vec<u8>, _>(idx)).unwrap()
41+
}
42+
43+
fn get_string_opt(&self, idx: usize) -> Option<String> {
44+
self.get::<Option<Vec<u8>>, _>(idx)
45+
.map(|v| String::from_utf8(v).unwrap())
46+
}
47+
}

src/mysql/query/column.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ impl SchemaQueryBuilder {
7777
#[cfg(feature = "sqlx-mysql")]
7878
impl From<&MySqlRow> for ColumnQueryResult {
7979
fn from(row: &MySqlRow) -> Self {
80-
use crate::sqlx_types::Row;
80+
use crate::mysql::discovery::GetMySqlValue;
8181
Self {
82-
column_name: row.get(0),
83-
column_type: row.get(1),
84-
is_nullable: row.get(2),
85-
column_key: row.get(3),
86-
column_default: row.get(4),
87-
extra: row.get(5),
88-
generation_expression: row.get(6),
89-
column_comment: row.get(7),
82+
column_name: row.get_string(0),
83+
column_type: row.get_string(1),
84+
is_nullable: row.get_string(2),
85+
column_key: row.get_string(3),
86+
column_default: row.get_string_opt(4),
87+
extra: row.get_string(5),
88+
generation_expression: row.get_string_opt(6),
89+
column_comment: row.get_string(7),
9090
}
9191
}
9292
}

src/mysql/query/foreign_key.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ impl SchemaQueryBuilder {
8585
#[cfg(feature = "sqlx-mysql")]
8686
impl From<&MySqlRow> for ForeignKeyQueryResult {
8787
fn from(row: &MySqlRow) -> Self {
88-
use crate::sqlx_types::Row;
88+
use crate::mysql::discovery::GetMySqlValue;
8989
Self {
90-
constraint_name: row.get(0),
91-
column_name: row.get(1),
92-
referenced_table_name: row.get(2),
93-
referenced_column_name: row.get(3),
94-
update_rule: row.get(4),
95-
delete_rule: row.get(5),
90+
constraint_name: row.get_string(0),
91+
column_name: row.get_string(1),
92+
referenced_table_name: row.get_string(2),
93+
referenced_column_name: row.get_string(3),
94+
update_rule: row.get_string(4),
95+
delete_rule: row.get_string(5),
9696
}
9797
}
9898
}

src/mysql/query/index.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,18 @@ impl SchemaQueryBuilder {
7676
#[cfg(feature = "sqlx-mysql")]
7777
impl From<&MySqlRow> for IndexQueryResult {
7878
fn from(row: &MySqlRow) -> Self {
79+
use crate::mysql::discovery::GetMySqlValue;
7980
use crate::sqlx_types::Row;
8081
Self {
8182
non_unique: row.get(0),
82-
index_name: row.get(1),
83-
column_name: row.get(2),
84-
collation: row.get(3),
83+
index_name: row.get_string(1),
84+
column_name: row.get_string_opt(2),
85+
collation: row.get_string_opt(3),
8586
sub_part: row.get(4),
86-
nullable: row.get(5),
87-
index_type: row.get(6),
88-
index_comment: row.get(7),
89-
expression: row.get(8),
87+
nullable: row.get_string(5),
88+
index_type: row.get_string(6),
89+
index_comment: row.get_string(7),
90+
expression: row.get_string_opt(8),
9091
}
9192
}
9293
}

src/mysql/query/table.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,16 @@ impl SchemaQueryBuilder {
8989
#[cfg(feature = "sqlx-mysql")]
9090
impl From<&MySqlRow> for TableQueryResult {
9191
fn from(row: &MySqlRow) -> Self {
92+
use crate::mysql::discovery::GetMySqlValue;
9293
use crate::sqlx_types::Row;
9394
Self {
94-
table_name: row.get(0),
95-
engine: row.get(1),
95+
table_name: row.get_string(0),
96+
engine: row.get_string(1),
9697
auto_increment: row.get(2),
97-
table_collation: row.get(3),
98-
table_comment: row.get(4),
99-
create_options: row.get(5),
100-
table_char_set: row.get(6),
98+
table_collation: row.get_string(3),
99+
table_comment: row.get_string(4),
100+
create_options: row.get_string(5),
101+
table_char_set: row.get_string(6),
101102
}
102103
}
103104
}

src/mysql/query/version.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ impl SchemaQueryBuilder {
2121
#[cfg(feature = "sqlx-mysql")]
2222
impl From<&MySqlRow> for VersionQueryResult {
2323
fn from(row: &MySqlRow) -> Self {
24-
use crate::sqlx_types::Row;
24+
use crate::mysql::discovery::GetMySqlValue;
2525
Self {
26-
version: row.get(0),
26+
version: row.get_string(0),
2727
}
2828
}
2929
}

tests/discovery/mysql/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ publish = false
88
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
99
sea-schema = { path = "../../../", default-features = false, features = [ "with-serde", "sqlx-mysql", "runtime-async-std-native-tls", "discovery", "debug-print" ] }
1010
serde_json = { version = "1" }
11-
sqlx = { version = "0.7" }
11+
sqlx = { version = "0.8" }
1212
env_logger = { version = "0" }
1313
log = { version = "0" }

tests/discovery/postgres/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ publish = false
88
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
99
sea-schema = { path = "../../../", default-features = false, features = [ "with-serde", "sqlx-postgres", "runtime-async-std-native-tls", "discovery", "debug-print" ] }
1010
serde_json = { version = "1" }
11-
sqlx = { version = "0.7" }
11+
sqlx = { version = "0.8" }
1212
env_logger = { version = "0" }
1313
log = { version = "0" }

tests/discovery/sqlite/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ publish = false
88
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
99
sea-schema = { path = "../../../", default-features = false, features = [ "with-serde", "sqlx-sqlite", "runtime-async-std-native-tls", "discovery", "debug-print" ] }
1010
serde_json = { version = "1" }
11-
sqlx = { version = "0.7" }
11+
sqlx = { version = "0.8" }

tests/live/mysql/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
99
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-mysql", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
1010
serde_json = { version = "1" }
11-
sqlx = { version = "0.7" }
11+
sqlx = { version = "0.8" }
1212
pretty_assertions = { version = "0.7" }
1313
regex = { version = "1" }
1414
env_logger = { version = "0" }

tests/live/postgres/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
99
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-postgres", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
1010
serde_json = { version = "1" }
11-
sqlx = { version = "0.7" }
11+
sqlx = { version = "0.8" }
1212
env_logger = { version = "0" }
1313
log = { version = "0" }
1414
pretty_assertions = { version = "0.7" }

tests/live/sqlite/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ sea-schema = { path = "../../../", default-features = false, features = [
1717
"sqlite",
1818
] }
1919
serde_json = { version = "1" }
20-
sqlx = { version = "0.7", features = [
20+
sqlx = { version = "0.8", features = [
2121
"sqlite",
2222
"runtime-async-std-native-tls",
2323
] }

tests/writer/mysql/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ publish = false
88
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
99
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-mysql", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
1010
serde_json = { version = "1" }
11-
sqlx = { version = "0.7" }
11+
sqlx = { version = "0.8" }
1212
env_logger = { version = "0" }
1313
log = { version = "0" }

tests/writer/postgres/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ pretty_assertions = { version = "0.7" }
99
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
1010
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-postgres", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
1111
serde_json = { version = "1" }
12-
sqlx = { version = "0.7" }
12+
sqlx = { version = "0.8" }
1313
env_logger = { version = "0" }
1414
log = { version = "0" }

tests/writer/sqlite/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ publish = false
88
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
99
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-sqlite", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
1010
serde_json = { version = "1" }
11-
sqlx = { version = "0.7" }
11+
sqlx = { version = "0.8" }

0 commit comments

Comments
 (0)