Skip to content

fix(datagrid): scope Copy as transforms to selected cells (#1929)#1930

Merged
datlechin merged 1 commit into
mainfrom
fix/copy-as-selected-cells-1929
Jul 21, 2026
Merged

fix(datagrid): scope Copy as transforms to selected cells (#1929)#1930
datlechin merged 1 commit into
mainfrom
fix/copy-as-selected-cells-1929

Conversation

@datlechin

Copy link
Copy Markdown
Member

What

Fixes #1929. When you select specific cells in the data grid, Copy as INSERT, UPDATE, JSON, CSV, and Markdown now include only the selected columns. Before, they included every column of the affected rows.

Selecting val_2.c and val_2.d, then Copy as INSERT:

-- before
INSERT INTO `myTable` (`column_a`, `column_b`, `column_c`, `column_d`) VALUES ('val_2.a', 'val_2.b', 'val_2.c', 'val_2.d');
-- after
INSERT INTO `myTable` (`column_c`, `column_d`) VALUES ('val_2.c', 'val_2.d');

Why

Plain Copy already reads the cell selection correctly. The "Copy as..." transforms collapsed the selection to row indices and rebuilt the column list from all visible columns, so which columns you selected was thrown away. This matches DataGrip's model (one selection-scoped extractor for every format) and the macOS HIG rule that a transformed Copy acts on the same selection as a plain Copy.

How

  • New selectedColumnProjection() resolves the selected columns (union, display order, hidden columns excluded) when a cell selection exists, and falls back to all visible columns for a whole-row or empty selection. INSERT, JSON, CSV, and Markdown route through it.
  • UPDATE gets a settableColumns set on SQLRowToStatementConverter that narrows the SET clause while the full row still feeds the WHERE. So SET narrows to the selected columns, WHERE keys on the primary key even when the primary key cell is not selected, a table with no primary key keeps identifying the row by its full contents, and a selection of only the primary key emits no statement instead of invalid SQL.
  • Discontiguous selections flatten to the column-union rectangle, matching DataGrip.

Rows / With Headers (raw TSV) and IN Clause are unchanged: plain Copy already serves cell-precise TSV, and IN Clause is already single-column.

Tests

  • Converter: SET restricted with the primary key in WHERE, no-primary-key full-row WHERE, primary-key-only selection emits nothing.
  • Coordinator: INSERT and CSV column scoping, UPDATE SET narrowed and keyed on an unselected primary key, no-primary-key full-row WHERE, discontiguous flatten. Rewrote a prior JSON test that asserted the old all-columns output.

Docs / Changelog

  • Updated the data grid "Select and Copy" docs.
  • Added a Fixed entry under [Unreleased].

@datlechin
datlechin merged commit b6a1c1a into main Jul 21, 2026
3 checks passed
@datlechin
datlechin deleted the fix/copy-as-selected-cells-1929 branch July 21, 2026 11:40
@mintlify

mintlify Bot commented Jul 21, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟢 Ready View Preview Jul 21, 2026, 11:40 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

ClipboardService.shared.writeText(converter.generateUpdates(rows: typedRows))

P2 Badge Preserve the clipboard when no UPDATE can be generated

When the cell selection contains only the primary-key column, generateUpdates intentionally returns an empty string, but this call still invokes writeText. NSPasteboardClipboardProvider.writeText clears the system pasteboard before writing, so using Copy as UPDATE in this valid selection erases whatever the user had copied previously instead of leaving the clipboard unchanged. Guard the generated SQL for emptiness before writing it.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mintlify

mintlify Bot commented Jul 21, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟡 Building Jul 21, 2026, 11:39 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

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.

Only selected cells should be included in Copy as... SQL statement(s)

1 participant