Skip to content

Show the rows a cascading delete will remove before it runs #3616

Closed

Description

@datlechin

Problem

Deleting rows in the grid stages them, and saving asks "Delete 5 rows?" (features/change-tracking.mdx:55). The prompt counts only the selected rows and says the delete cannot be undone (apple/TablePro/Core/ChangeTracking/BulkDeleteConfirmation.swift:13-21). It says nothing about rows in other tables.

A foreign key with ON DELETE CASCADE removes the child rows too, SET NULL rewrites them, and RESTRICT or NO ACTION makes the save fail. None of that shows before the save. Data Rewind brings back the rows TablePro deleted, but rows a cascade deleted stay deleted (features/change-tracking.mdx:132). Deleting three customers on production can take every order and order line with them, and the prompt reads the same as for three rows in a table nothing references.

Proposed solution

  • Before the delete confirmation, look up the foreign keys that reference the table, and follow cascading ones down to 5 levels.
  • Count the affected rows per table with read-only SELECT count(*) queries keyed on the staged rows' primary keys, under the connection's query timeout.
  • Show the counts in the confirmation: "Delete 3 rows from customers? This also deletes 41 rows from orders and 112 from order_items, and sets customer_id to NULL in 7 rows of invoices." Each line opens those rows in a new tab, filtered.
  • A RESTRICT or NO ACTION reference with rows behind it says the save will fail, and why, before anything is sent.
  • When the counts cannot be read in time, or a reference crosses into a schema the account cannot read, the prompt says so instead of showing a partial number as complete.

Done when: deleting 3 rows from customers, where orders cascades from it and order_items cascades from orders, shows both counts before the save on PostgreSQL, MySQL, SQLite and SQL Server, and a RESTRICT reference is reported before the save.

Alternatives considered

Query each child table by hand before deleting, or open the ER diagram to find which tables reference this one.

Platform

macOS

Related database type

N/A / General

Activity

  1. added
    enhancement
    platform-macos
    on Oct 19, 2026
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

    enhancementplatform-macos

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions