feat(editor): offer Execute All Statements in the Execute button's menu - #2233
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
Fixes #2230.
Root cause
Execute All Statementsis not a missing feature. It ships today and it is correct:runAllStatements()splits the tab withSQLStatementScanner.allStatements, thenexecuteMultipleStatementsWithParameterstakes a single lease on the tab's connection, runs the statements in order, and rolls back and stops on the first failure (QueryExecutionCoordinator+Parameters.swift:346-420).What it did not have was a way to reach it from the editor. It had exactly two entry points, both outside the editor pane: the Query menu and
Cmd+Shift+Return. The Execute split button, which is the control people actually reach for, offered onlyExecute Without Limit(QueryEditorView.swift:143-149). So the workaround is the one the reporter describes: select the whole tab by hand, then press Execute.That workaround dispatches identically to the command that was already there.
runQueryruns the selection when there is one and otherwise only the statement under the caret (MainContentCoordinator.swift:899-917), then splits that text with the same scanner and calls the samedispatchStatements. So this is an affordance gap, not a semantics bug.This is the second time it has been asked for. #770 requested "a dedicated button or shortcut to execute the entire script at once", and 823ddd6 shipped only the shortcut.
The fix
Add
Execute All Statementsas the first item of the existing Execute pull-down, wired tocoordinator.runAllStatements(), the same method the Query menu invokes.Two source lines of behaviour, plus a test:
QueryEditorView.swift: a new optionalonExecuteAllStatementscallback and the menu item, ordered aboveExecute Without Limitto mirror the Query menu.MainEditorContentView.swift:405: passescoordinator.runAllStatements().Design notes, since a few of these were deliberate rather than incidental:
Verified
Run through
verify.shagainst the branch, serially:generatebuild(Debug)uitest QueryExecuteMenuUITestslint(3 changed paths)The new suite has two cases, and the second exists because the first is not enough on its own.
onExecuteAllStatementsis optional, so deleting the wiring at the call site would not be a compile error and a presence-only assertion would stay green.testExecuteAllStatementsRunsEveryStatementInTheTabtherefore clicks the item and asserts both statements ran, one result tab each, with nothing selected.Before and after
Before, the menu held one item,
Execute Without Limit. After, it holdsExecute All Statementsabove it. I captured the open menu from the passing UI test and it is attached below by the author, sinceghcannot upload images itself.The page screenshot in
docs/features/sql-editor.mdxshows the button closed, so it stays accurate and needs no recapture.Known limitations
Cmd+Shift+Returnis attached with.optionalKeyboardShortcut, exactly as the sibling item attachesCmd+Option+Return, but SwiftUI draws no shortcut column here. Confirmed from the captured screenshot: neither item shows a chord. The shortcut is still discoverable in the Query menu and in Settings > Keyboard.!hasQueryText(MainSplitViewController+MenuValidation.swift:128-134). Both commands already return early on empty text, so this is cosmetic. It is left alone deliberately: the HIG says a menu should stay openable so people can learn the commands it contains, while the adjacent Explain menu disables the whole control, and resolving that inconsistency is a change to a shipped control that does not belong in this PR.Menuand a normalized-offset click on the chevron, because the leading half of the control runs the query. It passes locally. The opened menu is scoped to the window rather than matched by identifier, which is the workaroundResultTabPinUITestsrecords for the CI runner exposing a just-opened menu without one.Not included
The investigation verified five other defects in this subsystem. None ship here, because this change adds a second entry point to an existing command and creates no new code path. They are reported separately with repros. The one worth naming is that
SQLStatementScannerapplies backslash string escaping in every dialect, ignoringSqlDialect.requiresBackslashEscapesInSingleQuotes, which merges statements on PostgreSQL and can carry a write past the Safe Mode gate.