Skip to content

Commit

Permalink
Bump SQLx to 0.8 (#136)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
billy1624 authored Aug 9, 2024
1 parent b650684 commit 0679df9
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 44 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ path = "src/lib.rs"
[dependencies]
futures = { version = "0.3", default-features = false, optional = true, features = ["alloc"] }
sea-schema-derive = { version = "0.3.0", path = "sea-schema-derive", default-features = false }
sea-query = { version = "0.31.0", default-features = false, features = ["derive"] }
sea-query-binder = { version = "0.6.0", default-features = false, optional = true }
sea-query = { version = "0.32.0-rc.1", default-features = false, features = ["derive"] }
sea-query-binder = { version = "0.7.0-rc.1", default-features = false, optional = true }
serde = { version = "1", default-features = false, optional = true, features = ["derive"] }
sqlx = { version = "0.7", default-features = false, optional = true }
sqlx = { version = "0.8", default-features = false, optional = true }
log = { version = "0.4", default-features = false, optional = true }

[features]
Expand Down
19 changes: 18 additions & 1 deletion src/mysql/discovery/executor/real.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sea_query::{MysqlQueryBuilder, SelectStatement};
use sea_query_binder::SqlxBinder;
use sqlx::{mysql::MySqlRow, MySqlPool};
use sqlx::{mysql::MySqlRow, MySqlPool, Row};

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

Expand Down Expand Up @@ -28,3 +28,20 @@ impl Executor {
.await
}
}

pub trait GetMySqlValue {
fn get_string(&self, idx: usize) -> String;

fn get_string_opt(&self, idx: usize) -> Option<String>;
}

impl GetMySqlValue for MySqlRow {
fn get_string(&self, idx: usize) -> String {
String::from_utf8(self.get::<Vec<u8>, _>(idx)).unwrap()
}

fn get_string_opt(&self, idx: usize) -> Option<String> {
self.get::<Option<Vec<u8>>, _>(idx)
.map(|v| String::from_utf8(v).unwrap())
}
}
18 changes: 9 additions & 9 deletions src/mysql/query/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ impl SchemaQueryBuilder {
#[cfg(feature = "sqlx-mysql")]
impl From<&MySqlRow> for ColumnQueryResult {
fn from(row: &MySqlRow) -> Self {
use crate::sqlx_types::Row;
use crate::mysql::discovery::GetMySqlValue;
Self {
column_name: row.get(0),
column_type: row.get(1),
is_nullable: row.get(2),
column_key: row.get(3),
column_default: row.get(4),
extra: row.get(5),
generation_expression: row.get(6),
column_comment: row.get(7),
column_name: row.get_string(0),
column_type: row.get_string(1),
is_nullable: row.get_string(2),
column_key: row.get_string(3),
column_default: row.get_string_opt(4),
extra: row.get_string(5),
generation_expression: row.get_string_opt(6),
column_comment: row.get_string(7),
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/mysql/query/foreign_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ impl SchemaQueryBuilder {
#[cfg(feature = "sqlx-mysql")]
impl From<&MySqlRow> for ForeignKeyQueryResult {
fn from(row: &MySqlRow) -> Self {
use crate::sqlx_types::Row;
use crate::mysql::discovery::GetMySqlValue;
Self {
constraint_name: row.get(0),
column_name: row.get(1),
referenced_table_name: row.get(2),
referenced_column_name: row.get(3),
update_rule: row.get(4),
delete_rule: row.get(5),
constraint_name: row.get_string(0),
column_name: row.get_string(1),
referenced_table_name: row.get_string(2),
referenced_column_name: row.get_string(3),
update_rule: row.get_string(4),
delete_rule: row.get_string(5),
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/mysql/query/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,18 @@ impl SchemaQueryBuilder {
#[cfg(feature = "sqlx-mysql")]
impl From<&MySqlRow> for IndexQueryResult {
fn from(row: &MySqlRow) -> Self {
use crate::mysql::discovery::GetMySqlValue;
use crate::sqlx_types::Row;
Self {
non_unique: row.get(0),
index_name: row.get(1),
column_name: row.get(2),
collation: row.get(3),
index_name: row.get_string(1),
column_name: row.get_string_opt(2),
collation: row.get_string_opt(3),
sub_part: row.get(4),
nullable: row.get(5),
index_type: row.get(6),
index_comment: row.get(7),
expression: row.get(8),
nullable: row.get_string(5),
index_type: row.get_string(6),
index_comment: row.get_string(7),
expression: row.get_string_opt(8),
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/mysql/query/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,16 @@ impl SchemaQueryBuilder {
#[cfg(feature = "sqlx-mysql")]
impl From<&MySqlRow> for TableQueryResult {
fn from(row: &MySqlRow) -> Self {
use crate::mysql::discovery::GetMySqlValue;
use crate::sqlx_types::Row;
Self {
table_name: row.get(0),
engine: row.get(1),
table_name: row.get_string(0),
engine: row.get_string(1),
auto_increment: row.get(2),
table_collation: row.get(3),
table_comment: row.get(4),
create_options: row.get(5),
table_char_set: row.get(6),
table_collation: row.get_string(3),
table_comment: row.get_string(4),
create_options: row.get_string(5),
table_char_set: row.get_string(6),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/mysql/query/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ impl SchemaQueryBuilder {
#[cfg(feature = "sqlx-mysql")]
impl From<&MySqlRow> for VersionQueryResult {
fn from(row: &MySqlRow) -> Self {
use crate::sqlx_types::Row;
use crate::mysql::discovery::GetMySqlValue;
Self {
version: row.get(0),
version: row.get_string(0),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/discovery/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ publish = false
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
sea-schema = { path = "../../../", default-features = false, features = [ "with-serde", "sqlx-mysql", "runtime-async-std-native-tls", "discovery", "debug-print" ] }
serde_json = { version = "1" }
sqlx = { version = "0.7" }
sqlx = { version = "0.8" }
env_logger = { version = "0" }
log = { version = "0" }
2 changes: 1 addition & 1 deletion tests/discovery/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ publish = false
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
sea-schema = { path = "../../../", default-features = false, features = [ "with-serde", "sqlx-postgres", "runtime-async-std-native-tls", "discovery", "debug-print" ] }
serde_json = { version = "1" }
sqlx = { version = "0.7" }
sqlx = { version = "0.8" }
env_logger = { version = "0" }
log = { version = "0" }
2 changes: 1 addition & 1 deletion tests/discovery/sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ publish = false
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
sea-schema = { path = "../../../", default-features = false, features = [ "with-serde", "sqlx-sqlite", "runtime-async-std-native-tls", "discovery", "debug-print" ] }
serde_json = { version = "1" }
sqlx = { version = "0.7" }
sqlx = { version = "0.8" }
2 changes: 1 addition & 1 deletion tests/live/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-mysql", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
serde_json = { version = "1" }
sqlx = { version = "0.7" }
sqlx = { version = "0.8" }
pretty_assertions = { version = "0.7" }
regex = { version = "1" }
env_logger = { version = "0" }
Expand Down
2 changes: 1 addition & 1 deletion tests/live/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-postgres", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
serde_json = { version = "1" }
sqlx = { version = "0.7" }
sqlx = { version = "0.8" }
env_logger = { version = "0" }
log = { version = "0" }
pretty_assertions = { version = "0.7" }
2 changes: 1 addition & 1 deletion tests/live/sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sea-schema = { path = "../../../", default-features = false, features = [
"sqlite",
] }
serde_json = { version = "1" }
sqlx = { version = "0.7", features = [
sqlx = { version = "0.8", features = [
"sqlite",
"runtime-async-std-native-tls",
] }
Expand Down
2 changes: 1 addition & 1 deletion tests/writer/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ publish = false
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-mysql", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
serde_json = { version = "1" }
sqlx = { version = "0.7" }
sqlx = { version = "0.8" }
env_logger = { version = "0" }
log = { version = "0" }
2 changes: 1 addition & 1 deletion tests/writer/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ pretty_assertions = { version = "0.7" }
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-postgres", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
serde_json = { version = "1" }
sqlx = { version = "0.7" }
sqlx = { version = "0.8" }
env_logger = { version = "0" }
log = { version = "0" }
2 changes: 1 addition & 1 deletion tests/writer/sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ publish = false
async-std = { version = "1.8", features = [ "attributes", "tokio1" ] }
sea-schema = { path = "../../../", default-features = false, features = [ "sqlx-sqlite", "runtime-async-std-native-tls", "discovery", "writer", "debug-print" ] }
serde_json = { version = "1" }
sqlx = { version = "0.7" }
sqlx = { version = "0.8" }

0 comments on commit 0679df9

Please sign in to comment.