fix(ios): confirm Safe Mode writes before data-grid row saves and inserts#1438
Open
datlechin wants to merge 2 commits into
Open
fix(ios): confirm Safe Mode writes before data-grid row saves and inserts#1438datlechin wants to merge 2 commits into
datlechin wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On iOS, a connection's Safe Mode set to "Confirm Writes" is not enforced for data-grid edits. Editing a row in the row detail view and saving runs the UPDATE with no confirmation; inserting a row via the insert sheet does the same. The SQL query editor already prompts. Read-Only correctly blocks editing; only Confirm Writes was broken for grid writes.
Root cause
The three-way Safe Mode decision (block / confirm / proceed) was re-implemented ad-hoc at each write site.
QueryEditorViewdid it correctly; the grid sites (RowDetailViewModel.saveChanges,InsertRowView.insertRow) only checked the read-only half and skippedrequiresConfirmation.InsertRowViewwasn't even passedsafeModeLevel.Fix
Centralize the decision so no write path can skip it, then apply it at the grid sites:
SafeModeLevelgains aWritePermissionenum and awritePermissioncomputed var (in theTableProModelspackage, unit-tested).RowDetailViewModel.saveChanges()consultswritePermission; when confirmation is required it defers (setspendingWriteConfirmation, stashes the SQL) instead of executing.executePendingSave()runs it after the user confirms.RowDetailViewandInsertRowViewpresent a SwiftUI.alertwith a destructive confirm button and an explicit Cancel, naming the table.DataBrowserViewpassesconnection.safeModeLevelinto the insert sheet.QueryEditorViewswaps its inline chain forswitch writePermission(behavior-preserving), removing the last ad-hoc copy.DELETE is unchanged: it already shows a confirmation dialog for every connection, so a second prompt would double-confirm.
Design notes
.alert, not.confirmationDialog: alerts render identically on iPhone and iPad and always show an explicit Cancel.confirmationDialogbecomes a popover on iPad (regular size class) with no guaranteed Cancel row, which is wrong for a data-changing confirmation.Tests
TableProModelsTests/SafeModeLevelTests.swift:writePermissionfor all three levels.swift testpasses.RowDetailViewModelTests:confirmWritesdefers and runs no query;executePendingSave()then runs the UPDATE.Notes
.swiftformatuses--ifdefindent, which the installed swiftformat version rejects. Pre-existing and unrelated to this change.