Repository navigation
Description
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
RESTRICTorNO ACTIONreference 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