Skip to content

Grid looks up row keys on the editor tab's connection, not the result's #857

Closed

Description

@EVWorth

Severity: P1 (data safety).

#840 (PR #856) made grid saves take their table, connection, database and session from the result. ResultsGrid.tsx still reads three things from the active editor tab's connection and database instead of the result's resultSource:

  • the row-key lookup (useRowKey);
  • the row count;
  • the column layout.

The row key is the one that matters. It picks the primary-key columns that the UPDATE/DELETE ... WHERE clauses use. If the tab has moved to another connection or database since the query ran, the key comes from a different server's table with the same name. The WHERE clause can then name the wrong columns, or match more rows than intended.

How to see it

  1. Run SELECT * FROM t on connection A.
  2. Point the editor tab at connection B, which has a table t with a different primary key.
  3. Edit a cell and save. The key columns come from B's t.

Fix

Pass resultSource.connectionId and resultSource.database to useRowKey, the row count and the column layout. Refuse editing when resultSource is null, as the save already does.

Found while fixing #840.

Activity

  1. added a commit that references this issue on Oct 29, 2026
    841f381
  2. added a commit that references this issue on Oct 29, 2026
    ed2cd73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions