Skip to content

Commit bacb088

Browse files
green-newtristen
andauthored
feat: fix MySQL 8.0 information_schema changes (#2)
Co-authored-by: tristen <tristen_woodruff@caboces.org>
1 parent 761d61a commit bacb088

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
.vscode

crates/sqlx_gen/src/introspect/mysql.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async fn fetch_tables(pool: &MySqlPool, schemas: &[String]) -> Result<Vec<TableI
5959
placeholders.join(",")
6060
);
6161

62-
let mut q = sqlx::query_as::<_, (String, String, String, String, String, String, u32, String)>(&query);
62+
let mut q = sqlx::query_as::<_, (Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>, u32, Vec<u8>)>(&query);
6363
for schema in schemas {
6464
q = q.bind(schema);
6565
}
@@ -69,6 +69,14 @@ async fn fetch_tables(pool: &MySqlPool, schemas: &[String]) -> Result<Vec<TableI
6969
let mut current_key: Option<(String, String)> = None;
7070

7171
for (schema, table, col_name, data_type, column_type, nullable, ordinal, column_key) in rows {
72+
let schema = String::from_utf8(schema).expect("Could not convert schema name from UTF8 bytes");
73+
let table = String::from_utf8(table).expect("Could not convert schema name from UTF8 bytes");
74+
let col_name = String::from_utf8(col_name).expect("Could not convert col_name name from UTF8 bytes");
75+
let data_type = String::from_utf8(data_type).expect("Could not convert data_type name from UTF8 bytes");
76+
let column_type = String::from_utf8(column_type).expect("Could not convert column_type name from UTF8 bytes");
77+
let nullable = String::from_utf8(nullable).expect("Could not convert nullable name from UTF8 bytes");
78+
let column_key = String::from_utf8(column_key).expect("Could not convert column_key name from UTF8 bytes");
79+
7280
let key = (schema.clone(), table.clone());
7381
if current_key.as_ref() != Some(&key) {
7482
current_key = Some(key);

0 commit comments

Comments
 (0)