Skip to content

Commit b65d2da

Browse files
committed
fix(mysql): use column_type for data_type so tinyint(1) detects as bool
`information_schema.columns.data_type` strips length / precision — returns `tinyint` for both `tinyint(1)` and `tinyint(4)`, collapsing MySQL's idiomatic boolean type into a generic int. The result was the bool-checkbox cell editor emitting `"true"` / `"false"` to a column the parser had classified as `Int`, producing a stray "Invalid integer" toast on every check. `column_type` is the canonical column carrying what the user actually typed (`tinyint(1)`, `varchar(255)`, `decimal(10,2)`, `enum('a','b')`). Switching the introspection query to it fixes the bool detection and also gives the Structure tab the length / precision the user expects to see.
1 parent 50d9056 commit b65d2da

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • linux/crates/drivers/mysql/src

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,16 @@ impl Connection for MysqlConnection {
7676
}
7777

7878
async fn fetch_columns(&self, schema: Option<&str>, table: &str) -> Result<Vec<ColumnInfo>, DriverError> {
79+
// `column_type` is canonical: it carries the precision /
80+
// length the user typed (`tinyint(1)`, `varchar(255)`,
81+
// `decimal(10,2)`, `enum('a','b')`). `data_type` strips all
82+
// that — returns `tinyint` for both `tinyint(1)` and
83+
// `tinyint(4)`, which collapses MySQL's idiomatic boolean
84+
// type into a generic int and breaks the bool-detection
85+
// heuristic in `classify_type`. Prefer column_type for the
86+
// displayed `data_type`.
7987
let rows = sqlx::query(
80-
"SELECT CAST(column_name AS CHAR), CAST(data_type AS CHAR),
88+
"SELECT CAST(column_name AS CHAR), CAST(column_type AS CHAR),
8189
CAST(is_nullable AS CHAR), CAST(column_key AS CHAR),
8290
CAST(extra AS CHAR), CAST(column_default AS CHAR),
8391
CAST(generation_expression AS CHAR)

0 commit comments

Comments
 (0)