Skip to content

refactor(plugins)!: typed PluginCellValue for binary cells#1190

Merged
datlechin merged 11 commits into
mainfrom
refactor/typed-plugin-cell-value
May 10, 2026
Merged

refactor(plugins)!: typed PluginCellValue for binary cells#1190
datlechin merged 11 commits into
mainfrom
refactor/typed-plugin-cell-value

Conversation

@datlechin
Copy link
Copy Markdown
Member

@datlechin datlechin commented May 10, 2026

Summary

Fixes #1188 by replacing the implicit String-as-bytes contract with a typed PluginCellValue (.null / .text(String) / .bytes(Data)) that flows end-to-end from plugin to display to SQL emission. The visible 48-byte BYTEA value \xd38ce566...534f now displays as 0xD38CE566...534F with 48 bytes, and edits to high-byte binary cells round-trip correctly through the database.

  • Read pipeline: PluginQueryResult.rows: [[PluginCellValue]], QueryResult.rows: [[PluginCellValue]], Row.values: ContiguousArray<PluginCellValue>. Every driver plugin (PostgreSQL, MySQL, SQLite, MSSQL, Oracle, DuckDB, Cassandra, MongoDB, DynamoDB, BigQuery, etc.) emits .bytes(Data) for its native binary column types.
  • LibPQByteaDecoder: parses libpq text-format BYTEA (\xHH... hex and \nnn octal escape) into Data at the plugin boundary.
  • Edit + save pipeline: RowChange.cellChanges, RowChange.originalRow, ParameterizedStatement.parameters, and SQLStatementGenerator all consume typed PluginCellValue. .bytes(Data) parameters survive through the adapter and bind via libpq's binary parameter format (paramFormats[i] = 1) instead of being UTF-8-re-encoded text. The same path is in place for MySQL/MariaDB blob binding and SQLite sqlite3_bind_blob.
  • Hex editors: BlobHexEditorView (sidebar) and HexEditorContentView (popover) commit Data through new typed paths (commitBytes callback / setFieldToBytes / commitBinaryEdit) so a hex edit produces .bytes(Data) directly, not a Latin-1 String wrap.
  • Click routing: column-type wins over content heuristics in DataGridView+Click.swift. Binary bytes that incidentally contain \n, \f, or { no longer route through the multi-line/JSON text editor.

This rides the still-unreleased PluginKit ABI v11; no version bump.

Test plan

  • LibPQByteaDecoder* suites (26 tests): hex format edge cases, octal escapes, encode round-trip across all 256 byte values, exact-value regression for Wrong binary hex value #1188.
  • BlobFormattingService* suites (13 tests): byte count, compact hex, hex dump, editable hex, parse hex.
  • SQLStatementGeneratorBinaryTests (4 tests): .bytes newValue produces Data parameter (not String) on UPDATE/INSERT; .null produces nil (not String); exact Wrong binary hex value #1188 48-byte value round-trips through the SQL emission as Data.
  • Manual: opened _sqlx_migrations rows, confirmed display + sidebar + hex editor all show 48 bytes and the correct hex.
  • User to run full xcodebuild test.
  • User to verify cross-driver: MySQL VARBINARY edit + save, SQLite BLOB edit + save.

@datlechin datlechin merged commit ebe864a into main May 10, 2026
1 check passed
@datlechin datlechin deleted the refactor/typed-plugin-cell-value branch May 10, 2026 19:14
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.

Wrong binary hex value

1 participant