diff --git a/Cargo.toml b/Cargo.toml index dee1aacf..e67d281b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/src/mysql/discovery/executor/real.rs b/src/mysql/discovery/executor/real.rs index 31bfbae3..54d680f2 100644 --- a/src/mysql/discovery/executor/real.rs +++ b/src/mysql/discovery/executor/real.rs @@ -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}; @@ -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; +} + +impl GetMySqlValue for MySqlRow { + fn get_string(&self, idx: usize) -> String { + String::from_utf8(self.get::, _>(idx)).unwrap() + } + + fn get_string_opt(&self, idx: usize) -> Option { + self.get::>, _>(idx) + .map(|v| String::from_utf8(v).unwrap()) + } +} diff --git a/src/mysql/query/column.rs b/src/mysql/query/column.rs index 439204b6..932baced 100644 --- a/src/mysql/query/column.rs +++ b/src/mysql/query/column.rs @@ -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), } } } diff --git a/src/mysql/query/foreign_key.rs b/src/mysql/query/foreign_key.rs index 8896a43b..0c51657e 100644 --- a/src/mysql/query/foreign_key.rs +++ b/src/mysql/query/foreign_key.rs @@ -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), } } } diff --git a/src/mysql/query/index.rs b/src/mysql/query/index.rs index 2aa2c8a1..aa75f7ef 100644 --- a/src/mysql/query/index.rs +++ b/src/mysql/query/index.rs @@ -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), } } } diff --git a/src/mysql/query/table.rs b/src/mysql/query/table.rs index bef4b3e1..7ce0e073 100644 --- a/src/mysql/query/table.rs +++ b/src/mysql/query/table.rs @@ -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), } } } diff --git a/src/mysql/query/version.rs b/src/mysql/query/version.rs index 87384284..ad42d0e6 100644 --- a/src/mysql/query/version.rs +++ b/src/mysql/query/version.rs @@ -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), } } } diff --git a/tests/discovery/mysql/Cargo.toml b/tests/discovery/mysql/Cargo.toml index ed719066..89878109 100644 --- a/tests/discovery/mysql/Cargo.toml +++ b/tests/discovery/mysql/Cargo.toml @@ -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" } \ No newline at end of file diff --git a/tests/discovery/postgres/Cargo.toml b/tests/discovery/postgres/Cargo.toml index 34ebdc99..55dc7575 100644 --- a/tests/discovery/postgres/Cargo.toml +++ b/tests/discovery/postgres/Cargo.toml @@ -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" } \ No newline at end of file diff --git a/tests/discovery/sqlite/Cargo.toml b/tests/discovery/sqlite/Cargo.toml index 17db9bf9..e2a786ed 100644 --- a/tests/discovery/sqlite/Cargo.toml +++ b/tests/discovery/sqlite/Cargo.toml @@ -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" } \ No newline at end of file +sqlx = { version = "0.8" } \ No newline at end of file diff --git a/tests/live/mysql/Cargo.toml b/tests/live/mysql/Cargo.toml index a0917bdc..663680a2 100644 --- a/tests/live/mysql/Cargo.toml +++ b/tests/live/mysql/Cargo.toml @@ -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" } diff --git a/tests/live/postgres/Cargo.toml b/tests/live/postgres/Cargo.toml index b815e941..c7f37388 100644 --- a/tests/live/postgres/Cargo.toml +++ b/tests/live/postgres/Cargo.toml @@ -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" } diff --git a/tests/live/sqlite/Cargo.toml b/tests/live/sqlite/Cargo.toml index 47a6f2bd..af6712ea 100644 --- a/tests/live/sqlite/Cargo.toml +++ b/tests/live/sqlite/Cargo.toml @@ -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", ] } diff --git a/tests/writer/mysql/Cargo.toml b/tests/writer/mysql/Cargo.toml index 2c6e001e..10ae89da 100644 --- a/tests/writer/mysql/Cargo.toml +++ b/tests/writer/mysql/Cargo.toml @@ -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" } \ No newline at end of file diff --git a/tests/writer/postgres/Cargo.toml b/tests/writer/postgres/Cargo.toml index cf3bc973..9ff96324 100644 --- a/tests/writer/postgres/Cargo.toml +++ b/tests/writer/postgres/Cargo.toml @@ -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" } diff --git a/tests/writer/sqlite/Cargo.toml b/tests/writer/sqlite/Cargo.toml index 05bab2e6..8e3ea59f 100644 --- a/tests/writer/sqlite/Cargo.toml +++ b/tests/writer/sqlite/Cargo.toml @@ -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" } \ No newline at end of file +sqlx = { version = "0.8" } \ No newline at end of file