fix(plugin-mysql): classify BINARY/VARBINARY as blob to prevent data wipe on edit#1217
Merged
Merged
Conversation
…ental data wipe on edit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Clicking a
BINARY(N)orVARBINARY(N)cell to inspect it accidentally scheduled the column to be wiped to empty on the next Save. Reproduced onwide_events.hash_value BINARY(32):0x0F71…hex (correct read path).UPDATE … SET hash_value = '' WHERE …, destroying the original 32 bytes.Root cause
MariaDBPluginConnection.mysqlTypeToStringresolves the MySQL field type code to a type name. TheisBinaryflag is computed at the top but only consulted for the blob family (cases 249-252). Cases 253 and 254 returned"VARCHAR"/"CHAR"unconditionally:But in MySQL/MariaDB,
BINARY(N)has type code 254 with the binary flag set, andVARBINARY(N)has type code 253 with the binary flag set. Without consulting the flag, both types were returned as character strings.ColumnTypeClassifierthen mapped"CHAR"→.text(rawType: "CHAR"), so the data grid treated the column as text. Two consequences downstream:DataGridView.editEligibilitycorrectly blocks.blobfrom inline edit, but.textis allowed.PluginCellValue.bytes(_).asTextreturnsnil, so when the inline editor was populated fromrawValue.asTextthe editor opened empty."".Fix
Two lines:
Now
BINARY/VARBINARYcolumns 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
tablepro_demo→wide_events.hash_valuecell. Inline text editor does not open. Chevron is visible.hash_valuefield shows the bytes value, not blank.payloadJSON cell. Still works (separate type, unaffected).event_typeVARCHAR cell. Inline edit still works (non-binary VARCHAR unaffected).