Add table delete/truncate confirmation dialog#11
Conversation
Implement TablePlus-like confirmation dialog for delete/truncate table operations with options for: - Ignore foreign key checks - Cascade (delete dependent rows) Database-specific SQL generation: - MySQL/MariaDB: SET FOREIGN_KEY_CHECKS=0/1 - PostgreSQL: CASCADE keyword, session_replication_role - SQLite: PRAGMA foreign_keys
There was a problem hiding this comment.
Pull request overview
This PR adds a TablePlus-style confirmation dialog for table delete and truncate operations with support for database-specific options like ignoring foreign key checks and cascade operations. The implementation integrates across multiple layers including UI dialog, sidebar integration, coordinator SQL generation, and session state management.
Key Changes:
- New confirmation dialog component with database-specific option handling
- SQL generation for MySQL, PostgreSQL, and SQLite with foreign key and cascade support
- Session-level tracking of operation options for each table
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| TablePro/Models/TableOperationOptions.swift | Defines data models for operation options and operation types |
| TablePro/Models/ConnectionSession.swift | Adds tableOperationOptions dictionary to session state |
| TablePro/Views/Sidebar/TableOperationDialog.swift | New SwiftUI dialog component with database-specific option controls |
| TablePro/Views/Sidebar/SidebarView.swift | Integrates dialog presentation and manages operation confirmation flow |
| TablePro/Views/MainContentView.swift | Threads tableOperationOptions binding through view hierarchy |
| TablePro/Views/Main/MainContentNotificationHandler.swift | Passes tableOperationOptions to coordinator's saveChanges |
| TablePro/Views/Main/MainContentCoordinator.swift | Generates database-specific SQL with FK disable/enable and cascade options |
| TablePro/ContentView.swift | Adds session binding for tableOperationOptions and passes databaseType to sidebar |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Wrap multiple operations in BEGIN/COMMIT transaction for atomicity - Sort tables alphabetically for consistent execution order - Use SET CONSTRAINTS ALL DEFERRED for PostgreSQL (no superuser required) - PostgreSQL constraints auto-check at COMMIT
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Rename TableOperationType.delete to .drop for clarity - Reset dialog state (ignoreForeignKeys, cascade) on open - Restore pending operations on failure for retry capability - Include SQLite in transaction wrapping - Rename 'opts' variable to 'tableOptions' for readability - Add note when multiple tables selected (same options apply to all) - Use SET CONSTRAINTS ALL DEFERRED for PostgreSQL (no superuser required)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix PostgreSQL FK handling: return empty array for FK statements (PostgreSQL doesn't have a simple way to disable FK checks globally, rely on CASCADE option instead) - Add FK re-enable on error in catch block for MySQL/SQLite - Add sqlite_sequence reset for true TRUNCATE semantics (reset auto-increment) - Add docstrings to helper functions for better code documentation - Fix nested transaction issue when both cell changes and table ops exist (wrap in single transaction only when multiple operation types)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix SQL injection: escape embedded quotes in quoteIdentifier by doubling them (SQL standard escaping) - Move FK disable/enable statements outside transaction boundary to ensure they take effect even on rollback - Rename dropTableStatement parameter from tableName to quotedName for consistency with truncateStatements - Disable "Ignore foreign key checks" option for PostgreSQL with explanation text (use CASCADE instead) - Add onChange handlers to reset cascade/ignoreForeignKeys when their toggles become disabled, preventing silent override of user selection - Simplify confirmAndDismiss since values are now reset when disabled
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 17 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Test plan