Skip to content

Fix/blob text renders as hex - #329

Merged
Maxteabag merged 4 commits into
Maxteabag:mainfrom
sykesab:fix/blob-text-renders-as-hex
Sep 10, 2026
Merged

Fix/blob text renders as hex#329
Maxteabag merged 4 commits into
Maxteabag:mainfrom
sykesab:fix/blob-text-renders-as-hex

Conversation

@sykesab

@sykesab sykesab commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Decode bytes / bytearray / memoryview result values as UTF-8 before building the Arrow backend; fall back to 0x… hex only when the bytes are not valid UTF-8. Text stored in BLOB columns (for example JSON in a MySQL mediumblob) renders as text again, and the V value viewer detects JSON and opens tree mode.
  • Wrap the v cell-preview tooltip value in rich.text.Text so Textual does not parse cell content as Rich markup. Previously a value containing a closing-tag shape such as "[/api/v1]" raised MarkupError from the hover timer and exited the app.

Fixes #328.

Changes

  • sqlit/shared/ui/widgets_tables.py: normalize_arrow_value tries raw.decode("utf-8") and returns hex on UnicodeDecodeError. Invalid UTF-8 keeps the behaviour introduced for TUI crashes on raw binary result columns with UnicodeDecodeError after v1.6.3 upgrade #322.
  • sqlit/domains/results/ui/mixins/results.py: _show_cell_tooltip assigns Text(tooltip_value) instead of the bare string.
  • tests/ui/test_uuid_fastdatatable.py:
    • UTF-8 JSON bytes render as the decoded string, parametrized over bytes, bytearray, and memoryview.
    • Incrementally added UTF-8 bytes via add_rows render as the decoded string.
    • action_view_cell on a JSON blob containing [/api/v1] sets a Text tooltip with the decoded payload.

Test plan

uv run pytest tests/ui/test_uuid_fastdatatable.py -v
# 13 passed

uv run pytest tests/ui -q
# 411 passed

Manual: against a MySQL table with a mediumblob column holding JSON, run SELECT, confirm the cell shows the JSON text, press v and confirm the preview appears without crashing, press V and confirm tree mode opens.

@Maxteabag
Maxteabag merged commit 5ad4559 into Maxteabag:main Sep 10, 2026
@sykesab
sykesab deleted the fix/blob-text-renders-as-hex branch September 10, 2026 14:32
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.

Text stored in BLOB columns renders only as hex since 1.6.4

2 participants