Skip to content

fix(plugin-mysql): classify BINARY/VARBINARY as blob to prevent data wipe on edit#1217

Merged
datlechin merged 1 commit into
mainfrom
fix/mariadb-binary-varbinary-detection
May 11, 2026
Merged

fix(plugin-mysql): classify BINARY/VARBINARY as blob to prevent data wipe on edit#1217
datlechin merged 1 commit into
mainfrom
fix/mariadb-binary-varbinary-detection

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

Clicking a BINARY(N) or VARBINARY(N) cell to inspect it accidentally scheduled the column to be wiped to empty on the next Save. Reproduced on wide_events.hash_value BINARY(32):

  1. Cell displays the bytes as 0x0F71… hex (correct read path).
  2. User clicks the cell to view the value.
  3. Inline text editor opens but the field is empty.
  4. User clicks elsewhere to dismiss.
  5. The grid marks the cell as modified to empty — Save would UPDATE … SET hash_value = '' WHERE …, destroying the original 32 bytes.

Root cause

MariaDBPluginConnection.mysqlTypeToString resolves the MySQL field type code to a type name. The isBinary flag is computed at the top but only consulted for the blob family (cases 249-252). Cases 253 and 254 returned "VARCHAR" / "CHAR" unconditionally:

case 253: return "VARCHAR"
case 254: return "CHAR"

But in MySQL/MariaDB, BINARY(N) has type code 254 with the binary flag set, and VARBINARY(N) has type code 253 with the binary flag set. Without consulting the flag, both types were returned as character strings.

ColumnTypeClassifier then mapped "CHAR".text(rawType: "CHAR"), so the data grid treated the column as text. Two consequences downstream:

  1. DataGridView.editEligibility correctly blocks .blob from inline edit, but .text is allowed.
  2. PluginCellValue.bytes(_).asText returns nil, so when the inline editor was populated from rawValue.asText the editor opened empty.
  3. Focus-out committed the empty string back through the change manager, marking the cell as modified to "".

Fix

Two lines:

case 253: return isBinary ? "VARBINARY" : "VARCHAR"
case 254: return isBinary ? "BINARY" : "CHAR"

Now BINARY / VARBINARY columns classify as .blob. The data grid uses the chevron-triggered blob editor instead of inline text edit. Click-to-inspect no longer destroys data.

Test plan

  • Open MySQL tablepro_demowide_events.
  • Click any hash_value cell. Inline text editor does not open. Chevron is visible.
  • Click the chevron. Blob editor opens with the bytes displayed (hex or whatever the blob editor shows).
  • Right inspector pane: hash_value field shows the bytes value, not blank.
  • Click payload JSON cell. Still works (separate type, unaffected).
  • Click event_type VARCHAR cell. Inline edit still works (non-binary VARCHAR unaffected).
  • No accidental modifications after clicking around. Save dialog stays empty unless you actually edit something.

@datlechin datlechin merged commit b173394 into main May 11, 2026
2 checks passed
@datlechin datlechin deleted the fix/mariadb-binary-varbinary-detection branch May 11, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant