Skip to content

Commit 742510b

Browse files
datlechinclaude
andcommitted
fix(linux): MySQL information_schema VARBINARY decode + tinyint(1) test
list_tables and fetch_columns on MySQL 8 fail with "mismatched types; Rust type alloc::string::String (as SQL type VARCHAR) is not compatible with SQL type VARBINARY" because information_schema columns come back as VARBINARY in some setups. CAST every column to CHAR so sqlx decodes them as String. The value_roundtrip_all_types test asserted Int(1) for tinyint(1) but sqlx-mysql treats tinyint(1) as a Bool and our extract_value falls through to the BOOLEAN arm. Accept either Bool(true) or Int(1) — both are valid representations. Spotted via failing GitHub Actions runs since the start of the sprint; Postgres and unit tests were always green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent bd6b955 commit 742510b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

linux/crates/drivers/mysql/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct MysqlConnection {
5858
impl Connection for MysqlConnection {
5959
async fn list_tables(&self) -> Result<Vec<TableInfo>, DriverError> {
6060
let rows = sqlx::query(
61-
"SELECT table_schema, table_name
61+
"SELECT CAST(table_schema AS CHAR), CAST(table_name AS CHAR)
6262
FROM information_schema.tables
6363
WHERE table_schema = DATABASE()
6464
ORDER BY table_name",
@@ -77,7 +77,8 @@ impl Connection for MysqlConnection {
7777

7878
async fn fetch_columns(&self, table: &str) -> Result<Vec<ColumnInfo>, DriverError> {
7979
let rows = sqlx::query(
80-
"SELECT column_name, data_type, is_nullable, column_key
80+
"SELECT CAST(column_name AS CHAR), CAST(data_type AS CHAR),
81+
CAST(is_nullable AS CHAR), CAST(column_key AS CHAR)
8182
FROM information_schema.columns
8283
WHERE table_schema = DATABASE() AND table_name = ?
8384
ORDER BY ordinal_position",

linux/crates/drivers/mysql/tests/integration.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ async fn value_roundtrip_all_types() {
144144
let row = &q.rows[0];
145145

146146
match &row[0] {
147+
Value::Bool(true) => {}
147148
Value::Int(1) => {}
148-
v => panic!("expected tinyint(1) -> Int(1), got {v:?}"),
149+
v => panic!("expected tinyint(1) -> Bool(true) or Int(1), got {v:?}"),
149150
}
150151
assert!(matches!(row[1], Value::Int(123)));
151152
assert!(matches!(row[2], Value::Int(456_789)));

0 commit comments

Comments
 (0)