Repository navigation
feat(datagrid): read binary columns holding UTF-8 as text - #2603
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Fixes #2599.
The bug
ValueDisplayFormat.applicableColumnTypesmapped binary columns to[.raw, .uuid], so the Display As submenu on aVARBINARYorBLOBheader offered Raw Value and UUID and nothing else. A binary column holding UTF-8, which is where MySQL applications put JSON payloads, tokens and message bodies, had no readable form at all: every cell rendered0x7b226576656e74….Smart value detection could not help either.
ValueDisplayDetectorreads its samples throughPluginCellValue.asText, which isnilfor every.bytescell, so a binary column was invisible to it.The fix
A new
ValueDisplayFormat.text, applicable to binary columns. Everything the grid renders funnels throughCellDisplayFormatter.format, so one case reaches the grid, the per-column value filter, column-width measurement, VoiceOver and single-cell copy at once.BinaryTextDecoderis the whole decision, kept pure and separate because both the format and the detector ask it the same question:0x00is trimmed, but only on a column whose base type name isBINARY. That is the one type that right-pads, so without the trim a fixed-width column holding text could never read as text, and with the trim anywhere else0x6100in aBLOBwould report asa.LONGBLOBnever builds a multi-gigabyteStringon the main thread. A cut value carries a…, soCmd+Ccannot hand back a prefix as if it were the whole thing. A cut that splits a UTF-8 sequence gives up at most three bytes; a whole value never does, since dropping bytes there would accept binary that happens to open with readable characters.A value the decoder refuses falls back to the hex it always showed, per cell. So an image sitting in a column set to Text still reads as
0x89504E…while its neighbours read as text.Detection is per column and every sample has to agree: all sampled values decode, and at least one carries content. A
.textsample opts the column out entirely, which keeps MongoDB's driver-decoded legacy UUIDs on the byte order their connection chose. UUID detection still runs first, so an id-likeBINARY(16)is unaffected.ValueDisplayFormatService.applyFormat(_ String:)now returnsString?. "This format cannot render this value" had no spelling before, and theDataoverload was already optional..uuidand the timestamps are unchanged; only.textever answers nil.The cell length cap and line-break flattening moved into
CellDisplayFormatter.fitToCelland now cover the binary branch too. Hex never needed it, since a blob cell was capped at 64 bytes. Decoded text does.Find had to move with it
FindMatcher.isSearchableexcluded every binary column outright, andrunFinddropped any cell whose value was not already a string. Both were right while hex was the only thing a binary column could show, and both would have silently skipped a column now displaying readable text: the user searches forsignup, sees it on screen, and Find reports nothing.A binary column is now searchable when its display format turns bytes into characters, which
ValueDisplayFormat.rendersBinaryAsTextanswers. That covers UUID as well as Text, so aBINARY(16)id column showing550e8400-…is searchable too. It was not before.The format is a column-level choice and the fallback to hex is per value, so the two gates are separate: the column passes on its format, and each cell passes only if the format actually rendered those bytes. Without the second one a term like
8950would match a0x89504E47still sitting in a Text column.Server-side escalation is deliberately unchanged:
isServerSearchablegates what can go into aLIKEwithout a cast, andbytea LIKE '…'fails the whole query on PostgreSQL.Scope
Display only. A binary cell keeps the hex editor and the hex popover, exactly as Display As > UUID behaves today, and nothing about what is written changes. No PluginKit change, so no ABI bump.
Tests
47 new cases across six suites. The thirteen suites that own the touched types run 145 cases, all passing.
BinaryTextDecoderTests(21 new): real byte sequences, including a PNG header, a gzip header, a UUID's 16 bytes, a packed IPv4 address,BINARY(N)padding against the same bytes in aBLOBand aVARBINARY, an all-padding value, an embedded NUL, a split multi-byte sequence at the cap, the truncation marker, and the byte-per-character carrier string a driver hands over.ValueDisplayDetectorTests(12 new): the mixed column, the all-empty column, the driver-decoded column, the trailing NUL under both column widths, and UUID still winning on an id-likeBINARY(16).TableViewCoordinatorFindTests(3 new): Find over a Text column, over a cell that fell back to hex, and over a column left on Raw.CellDisplayFormatterTests(8 new): the render path, the hex fallback, the padding policy, line-break flattening and the length cap.FindMatcherTestsandValueDisplayFormatTests: searchability per format, and menu contents per column type with MongoDB included.No
TableProUITestscoverage. The flow is the data grid's column header context menu, and the header is entirely custom-drawn chrome with no addressable element; menu item identifiers also differ on the CI runner. The behaviour is fully covered by the unit suites instead.Docs
features/json-viewer.mdxowns the Display As table and gained the Text row plus the per-cell fallback.features/data-grid.mdxandcustomization/data-settings.mdxeach carried a copy of the format list; both now point at the table rather than restating it. The Settings row also claimed smart value detection renders JSON and PHP serialized columns, which it never did:ValueDisplayDetectoronly ever returned UUID and Unix timestamps.Before / After
Same SQLite fixture in both:
events.payloadis aBLOBholding UTF-8 JSON,events.digestis aBLOBholding 20 random bytes. Captured from 0.70.0 and from this branch, both against throwaway storage.Before, every value in both columns reads as hex:
After,
payloadreads as text anddigestcorrectly stays hex, with no user action:Full-window PNGs are attached below.
Fixes #2599
https://claude.ai/code/session_01RuTox52znCzCJy8hHstiXU