From da64b21c5690174a8ac1f3819c7cf5e8a6f22834 Mon Sep 17 00:00:00 2001 From: rumitvn <160252724+rumitvn@users.noreply.github.com> Date: Wed, 10 Jun 2026 22:46:58 +0700 Subject: [PATCH] fix(sql): decode MySQL BINARY/VARBINARY columns MySQL reports VARCHAR columns with a binary collation (e.g. utf8mb4_bin) as VARBINARY, which fell through to the unsupported-datatype error ("unsupported datatype: VARBINARY"). Add BINARY and VARBINARY to the binary-decoding arm so they are returned as byte arrays like the other binary types. Also fix a typo (TINIYBLOB) that prevented TINYBLOB columns from being decoded. Closes #2274 --- .changes/sql-mysql-varbinary.md | 6 ++++++ plugins/sql/src/decode/mysql.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/sql-mysql-varbinary.md diff --git a/.changes/sql-mysql-varbinary.md b/.changes/sql-mysql-varbinary.md new file mode 100644 index 0000000000..32e74f66aa --- /dev/null +++ b/.changes/sql-mysql-varbinary.md @@ -0,0 +1,6 @@ +--- +"sql": patch +"sql-js": patch +--- + +Fix MySQL `BINARY` and `VARBINARY` columns failing to decode with `unsupported datatype: VARBINARY`. This notably affects `VARCHAR` columns using a binary collation such as `utf8mb4_bin`, which MySQL reports as `VARBINARY`. They are now decoded as byte arrays like the other binary types. Also fix a typo (`TINIYBLOB`) that prevented `TINYBLOB` columns from being decoded. diff --git a/plugins/sql/src/decode/mysql.rs b/plugins/sql/src/decode/mysql.rs index 53fd20c7c4..e8f4da5694 100644 --- a/plugins/sql/src/decode/mysql.rs +++ b/plugins/sql/src/decode/mysql.rs @@ -86,7 +86,7 @@ pub(crate) fn to_json(v: MySqlValueRef) -> Result { } } "JSON" => ValueRef::to_owned(&v).try_decode().unwrap_or_default(), - "TINIYBLOB" | "MEDIUMBLOB" | "BLOB" | "LONGBLOB" => { + "BINARY" | "VARBINARY" | "TINYBLOB" | "MEDIUMBLOB" | "BLOB" | "LONGBLOB" => { if let Ok(v) = ValueRef::to_owned(&v).try_decode::>() { JsonValue::Array(v.into_iter().map(|n| JsonValue::Number(n.into())).collect()) } else {