Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(editor): add execute-all-SQL toolbar button and Alt+X shortcut (#12778)

lxk9556e84a7ed5de1
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index afb52e6945..2afc5da3e3 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -140,6 +140,7 @@ import {
isDisconnectAllActiveConnectionsShortcut,
isEditTableStructureShortcut,
isExecuteSqlInNewResultTabShortcut,
+ isExecuteAllSqlShortcut,
isExecuteSqlShortcut,
isDefaultQueryShortcutTarget,
isFocusSearchShortcut,
@@ -1119,6 +1120,14 @@ function requestActiveEditorExecute(source?: "pointer" | "keyboard", tabId?: str
void tryExecute(undefined, targetTabId ? { tabId: targetTabId } : undefined);
}
+function requestActiveEditorExecuteAll(_source?: "pointer" | "keyboard", tabId?: string) {
+ pendingToolbarExecutionSnapshot.value = undefined;
+ const targetTabId = tabId ?? activeTab.value?.id;
+ if (contentAreaRef.value?.requestQueryEditorExecuteAll?.(targetTabId)) return;
+ const tab = targetTabId ? queryStore.tabs.find((t) => t.id === targetTabId) : activeTab.value;
+ void tryExecute(tab?.sql ?? undefined, targetTabId ? { tabId: targetTabId } : undefined);
+}
+
function requestActiveEditorExecuteInNewResultTab(source?: "pointer" | "keyboard", tabId?: string) {
const snapshot = pendingToolbarExecutionSnapshot.value;
pendingToolbarExecutionSnapshot.value = undefined;
@@ -1179,6 +1188,7 @@ provide(EDITOR_TOOLBAR_ACTIONS, {
connectionRequiredSignalFor: (tabId: string) => (connectionRequiredTabId.value === tabId ? connectionRequiredSignal.value : 0),
captureExecutionSnapshot: captureActiveEditorExecutionSnapshot,
toolbarExecute: requestActiveEditorExecute,
+ toolbarExecuteAll: requestActiveEditorExecuteAll,
toolbarExecuteInNewResultTab: requestActiveEditorExecuteInNewResultTab,
cancelExecution: (tabId: string) => cancelActiveExecution(tabId),
explain: (tabId: string) => tryExplain(undefined, { tabId }),
@@ -4853,6 +4863,12 @@ async function handleKeydown(e: KeyboardEvent) {
if (!e.repeat && !activeTab.value.isExecuting && !contentAreaRef.value?.shouldBlockQueryEditorExecutionShortcut?.(e)) requestActiveEditorExecuteInNewResultTab();
return;
}
+ if (activeTab.value?.mode === "query" && isExecuteAllSqlShortcut(e, shortcuts) && e.target instanceof Element && e.target.closest("[data-query-editor-root]")) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!e.repeat && !activeTab.value.isExecuting && !contentAreaRef.value?.shouldBlockQueryEditorExecutionShortcut?.(e)) requestActiveEditorExecuteAll();
+ return;
+ }
if (activeTab.value?.mode === "query" && isExecuteSqlShortcut(e, shortcuts) && e.target instanceof Element && e.target.closest("[data-query-editor-root]")) {
e.preventDefault();
e.stopPropagation();
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index 1ba7e40157..1f7279bb7d 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -283,17 +283,18 @@ const liveFontSize = ref(settingsStore.editorSettings.fontSize);
const gestureStartFontSize = ref(settingsStore.editorSettings.fontSize);
const isGestureZooming = ref(false);
-const { pickerVisible, pickerCandidates, pickerActiveIndex, pickerAnchor, captureExecutionSnapshot, requestExecute, requestExecuteInNewResultTab, onPickerActiveIndexChange, onPickerConfirm, closePicker, sqlExecutionSnapshotFromView, sqlExecutionSnapshotForRange } = useQueryEditorExecution({
- props,
- view,
- editorRef,
- settingsStore,
- executionViewportOwnership,
- sqlStatementParameterOptions,
- setPreviewRange,
- emitExecutionRequest,
- onExecute: (source) => emit("execute", source),
-});
+const { pickerVisible, pickerCandidates, pickerActiveIndex, pickerAnchor, captureExecutionSnapshot, requestExecute, requestExecuteAll, requestExecuteInNewResultTab, onPickerActiveIndexChange, onPickerConfirm, closePicker, sqlExecutionSnapshotFromView, sqlExecutionSnapshotForRange } =
+ useQueryEditorExecution({
+ props,
+ view,
+ editorRef,
+ settingsStore,
+ executionViewportOwnership,
+ sqlStatementParameterOptions,
+ setPreviewRange,
+ emitExecutionRequest,
+ onExecute: (source) => emit("execute", source),
+ });
const searchPanelRef = ref<InstanceType<typeof EditorSearchPanel>>();
const gotoLinePanelRef = ref<InstanceType<typeof EditorGotoLinePanel>>();
@@ -989,6 +990,12 @@ function executeFromContextMenu() {
focusEditor();
}
+function executeAllFromContextMenu() {
+ if (!canExecuteContextSql.value) return;
+ requestExecuteAll();
+ focusEditor();
+}
+
function executeInNewResultTabFromContextMenu() {
if (!canExecuteContextSql.value) return;
requestExecuteInNewResultTab();
@@ -1261,6 +1268,7 @@ function navigateStatementFromView(currentView: EditorViewType, direction: State
const contextMenuActions: QueryEditorContextMenuActions = {
executeFromContextMenu,
+ executeAllFromContextMenu,
executeInNewResultTabFromContextMenu,
explainFromContextMenu,
requestPreviewChanges,
@@ -1350,6 +1358,14 @@ function runKeymapExtension(codeMirrorKeymap: (typeof import("@codemirror/view")
(currentView) => shouldBlockExecutionShortcut(undefined, currentView),
() => !props.isExecuting,
);
+ const executeAllBindings = props.hideExecutionControls
+ ? []
+ : createQueryEditorExecutionShortcutBindings(
+ shortcuts.executeAllSql,
+ () => requestExecuteAll(),
+ (currentView) => shouldBlockExecutionShortcut(undefined, currentView),
+ () => !props.isExecuting,
+ );
const executeInNewResultTabBindings = props.hideExecutionControls
? []
: createQueryEditorExecutionShortcutBindings(
@@ -1439,6 +1455,7 @@ function runKeymapExtension(codeMirrorKeymap: (typeof import("@codemirror/view")
...binding(shortcuts.gotoLine, openGotoLine),
...replaceShortcutBindings,
...executeInNewResultTabBindings,
+ ...executeAllBindings,
...executeBindings,
...explainBindings,
...binding(shortcuts.saveSql, () => {
@@ -3044,6 +3061,7 @@ defineExpose({
cancelGutterExecutionViewport,
shouldBlockExecutionShortcut,
requestExecute,
+ requestExecuteAll,
requestExecuteInNewResultTab,
requestPreviewChanges,
captureExecutionSnapshot,
diff --git a/apps/desktop/src/components/editor/QueryEditorContextMenu.vue b/apps/desktop/src/components/editor/QueryEditorContextMenu.vue
index 060ac530a2..830252ae60 100644
--- a/apps/desktop/src/components/editor/QueryEditorContextMenu.vue
+++ b/apps/desktop/src/components/editor/QueryEditorContextMenu.vue
@@ -14,6 +14,7 @@ import {
Columns3,
Download,
Eye,
+ FastForward,
FileCode,
FoldVertical,
GitBranch,
@@ -60,6 +61,7 @@ export interface QueryEditorContextMenuState {
export interface QueryEditorContextMenuActions {
executeFromContextMenu: () => void;
+ executeAllFromContextMenu?: () => void;
executeInNewResultTabFromContextMenu: () => void;
explainFromContextMenu?: () => void;
requestPreviewChanges: (sql?: string) => void;
@@ -172,6 +174,18 @@ const contextMenuItems = computed<ContextMenuItem[]>(() => {
icon: Play,
shortcut: shortcuts.executeSql,
},
+ ...(actions.executeAllFromContextMenu
+ ? [
+ {
+ sidebarActionId: "toolbar.executeAllSql",
+ label: t("toolbar.executeAllSql"),
+ action: actions.executeAllFromContextMenu,
+ disabled: !canExecuteContextSql,
+ icon: FastForward,
+ shortcut: shortcuts.executeAllSql,
+ },
+ ]
+ : []),
{
sidebarActionId: "settings.shortcutExecuteSqlInNewResultTab",
label: t("settings.shortcutExecuteSqlInNewResultTab"),
diff --git a/apps/desktop/src/components/editor/__tests__/QueryEditor.componentSplit.integration.spec.ts b/apps/desktop/src/components/editor/__tests__/QueryEditor.componentSplit.integration.spec.ts
index 4fc5e1efdf..c64edefc0c 100644
--- a/apps/desktop/src/components/editor/__tests__/QueryEditor.componentSplit.integration.spec.ts
+++ b/apps/desktop/src/components/editor/__tests__/QueryEditor.componentSplit.integration.spec.ts
@@ -149,6 +149,7 @@ describe("QueryEditor component split integration", () => {
"cancelGutterExecutionViewport",
"shouldBlockExecutionShortcut",
"requestExecute",
+ "requestExecuteAll",
"requestExecuteInNewResultTab",
"requestPreviewChanges",
"captureExecutionSnapshot",
@@ -193,6 +194,24 @@ describe("QueryEditor component split integration", () => {
expect(source.selectionTo).toBe(executeMode === "current" ? 18 : props.modelValue.length);
});
+ it.each(["current", "all"] as const)("executes the full document despite a selection and the %s execution mode", async (executeMode) => {
+ const { editor, host, view, props, settingsStore, onExecute } = await mountEditor();
+ settingsStore.editorSettings.executeMode = executeMode;
+ settingsStore.editorSettings.showExecutionTargetPicker = true;
+ view.dispatch({ selection: EditorSelection.range(10, 18) });
+
+ expect(editor.requestExecuteAll()).toBe(true);
+ await nextTick();
+
+ expect(onExecute).toHaveBeenCalledTimes(1);
+ const snapshot = onExecute.mock.calls[0][0];
+ expect(snapshot.fullSql).toBe(props.modelValue);
+ expect(snapshot.selectedSql).toBe(props.modelValue);
+ expect(snapshot.selectionFrom).toBe(0);
+ expect(snapshot.selectionTo).toBe(props.modelValue.length);
+ expect(host.querySelector('[role="listbox"]')).toBeNull();
+ });
+
it("keeps the new-result-tab shortcut independent of the optional picker", async () => {
const { editor, host, settingsStore, onExecute, onExecuteInNewResultTab } = await mountEditor();
settingsStore.editorSettings.showExecutionTargetPicker = true;
diff --git a/apps/desktop/src/components/editor/useQueryEditorExecution.ts b/apps/desktop/src/components/editor/useQueryEditorExecution.ts
index b76163dd45..9d8354c70f 100644
--- a/apps/desktop/src/components/editor/useQueryEditorExecution.ts
+++ b/apps/desktop/src/components/editor/useQueryEditorExecution.ts
@@ -12,6 +12,7 @@ interface RequestExecuteOptions {
ignoreSelection?: boolean;
bypassPicker?: boolean;
openInNewResultTab?: boolean;
+ forceExecuteAll?: boolean;
}
interface QueryEditorExecutionOptions {
@@ -66,36 +67,62 @@ export function useQueryEditorExecution(options: QueryEditorExecutionOptions) {
return requestExecute({ bypassPicker: true, openInNewResultTab: true });
}
+ function requestExecuteAll(options: Omit<RequestExecuteOptions, "forceExecuteAll"> = {}) {
+ if (props.isExecuting) return false;
+ return requestExecute({ ...options, ignoreSelection: true, forceExecuteAll: true, bypassPicker: true });
+ }
+
function requestExecuteFromView(currentView: EditorViewType, cursorPos: number, options: RequestExecuteOptions = {}) {
const selection = currentView.state.selection.main;
- if (!options.ignoreSelection && !selection.empty) {
+ if (!options.ignoreSelection && !options.forceExecuteAll && !selection.empty) {
// Has manual selection → execute directly, skip picker.
emitExecutionRequest(sqlExecutionSnapshotFromView(currentView), options.openInNewResultTab);
return true;
}
if (!supportsExecutionTargetPicker(props.databaseType)) {
- emitExecutionRequest(sqlExecutionSnapshotFromView(currentView), options.openInNewResultTab);
+ const snapshot = options.forceExecuteAll
+ ? sqlExecutionSnapshotForRange(currentView, {
+ sql: currentView.state.doc.toString(),
+ from: 0,
+ to: currentView.state.doc.length,
+ })
+ : sqlExecutionSnapshotFromView(currentView);
+ emitExecutionRequest(snapshot, options.openInNewResultTab);
return true;
}
// No selection → resolve the execution target, optionally via the picker.
const doc = currentView.state.doc.toString();
const parameterOptions = sqlStatementParameterOptions();
const candidates = buildExecutionCandidates(doc, cursorPos, props.databaseType, parameterOptions);
- const executeMode = settingsStore.editorSettings.executeMode;
+ const executeMode = options.forceExecuteAll ? "all" : settingsStore.editorSettings.executeMode;
if (candidates.length === 0) {
if (executeMode === "current") toast(t("editor.noExecutableStatementAtCursor"), 3000);
+ else if (doc.trim()) {
+ emitExecutionRequest(sqlExecutionSnapshotForRange(currentView, { sql: doc, from: 0, to: doc.length }), options.openInNewResultTab);
+ }
return true;
}
- const candidate = executionCandidateForMode(candidates, executeMode, {
- executeAllOnBlankLine: settingsStore.editorSettings.executeAllOnBlankLine,
- });
+ const candidate =
+ executionCandidateForMode(candidates, executeMode, {
+ executeAllOnBlankLine: settingsStore.editorSettings.executeAllOnBlankLine,
+ }) ??
+ (options.forceExecuteAll
+ ? {
+ kind: "all" as const,
+ supportedKinds: ["all" as const],
+ label: "allStatements",
+ sql: doc,
+ from: 0,
+ to: doc.length,
+ }
+ : null);
if (!candidate) {
toast(t("editor.noExecutableStatementAtCursor"), 3000);
return true;
}
// The execution shortcut keeps executing the configured target (cursor/all) directly:
// it stays keyboard-driven and never pops the picker, which is reserved for click entry points.
- if (options.bypassPicker || !settingsStore.editorSettings.showExecutionTargetPicker || !hasMultipleExecutionTargets(doc, props.databaseType, parameterOptions)) {
+ if (options.bypassPicker || options.forceExecuteAll || !settingsStore.editorSettings.showExecutionTargetPicker || !hasMultipleExecutionTargets(doc, props.databaseType, parameterOptions)) {
emitExecutionRequest(sqlExecutionSnapshotForRange(currentView, candidate), options.openInNewResultTab);
return true;
}
@@ -174,6 +201,7 @@ export function useQueryEditorExecution(options: QueryEditorExecutionOptions) {
pickerAnchor,
captureExecutionSnapshot,
requestExecute,
+ requestExecuteAll,
requestExecuteInNewResultTab,
requestExecuteFromView,
executionPickerAnchor,
diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue
index 20ad9a15d4..0f8fcd37ce 100644
--- a/apps/desktop/src/components/layout/ContentArea.vue
+++ b/apps/desktop/src/components/layout/ContentArea.vue
@@ -1836,6 +1836,10 @@ function requestQueryEditorExecute() {
return queryEditorRef.value?.requestExecute();
}
+function requestQueryEditorExecuteAll() {
+ return queryEditorRef.value?.requestExecuteAll();
+}
+
function captureQueryEditorExecutionSnapshot() {
if (!sourceSectionActive.value) return;
return queryEditorRef.value?.captureExecutionSnapshot();
@@ -2006,6 +2010,7 @@ defineExpose({
refreshQueryEditorCompletionCache,
handleModRTarget,
requestQueryEditorExecute,
+ requestQueryEditorExecuteAll,
captureQueryEditorExecutionSnapshot,
requestQueryEditorExecuteInNewResultTab,
requestQueryEditorPreviewChanges,
diff --git a/apps/desktop/src/components/layout/EditorGroup.vue b/apps/desktop/src/components/layout/EditorGroup.vue
index 22439fdefe..c87a879b58 100644
--- a/apps/desktop/src/components/layout/EditorGroup.vue
+++ b/apps/desktop/src/components/layout/EditorGroup.vue
@@ -87,6 +87,7 @@ defineExpose({
refreshQueryEditorCompletionCache: () => activeSurfaceRef.value?.refreshQueryEditorCompletionCache() ?? false,
handleModRTarget: (target: Element) => activeSurfaceRef.value?.handleModRTarget(target) ?? false,
requestQueryEditorExecute: () => activeSurfaceRef.value?.requestQueryEditorExecute() ?? false,
+ requestQueryEditorExecuteAll: () => activeSurfaceRef.value?.requestQueryEditorExecuteAll() ?? false,
captureQueryEditorExecutionSnapshot: () => activeSurfaceRef.value?.captureQueryEditorExecutionSnapshot(),
requestQueryEditorExecuteInNewResultTab: () => activeSurfaceRef.value?.requestQueryEditorExecuteInNewResultTab() ?? false,
requestQueryEditorPreviewChanges: async (stackSql?: string) => (await activeSurfaceRef.value?.requestQueryEditorPreviewChanges(stackSql)) ?? false,
@@ -242,6 +243,7 @@ const groupExecutableSql = computed(() => {
@dismiss-auto-commit-session-txn-rolled-back="activeTab && (activeTab.autoCommitSessionTxnRolledBack = false)"
@execute-pointer-down="toolbar.captureExecutionSnapshot(activeTab.id)"
@toolbar-execute="toolbar.toolbarExecute($event, activeTab.id)"
+ @toolbar-execute-all="toolbar.toolbarExecuteAll($event, activeTab.id)"
@toolbar-execute-in-new-result-tab="toolbar.toolbarExecuteInNewResultTab($event, activeTab.id)"
@multi-execute="toolbar.multiExecute()"
@preview-changes="activeTab && toolbar.previewChanges(activeTab.id)"
diff --git a/apps/desktop/src/components/layout/EditorToolbar.vue b/apps/desktop/src/components/layout/EditorToolbar.vue
index f478c57d3f..fd090141bc 100644
--- a/apps/desktop/src/components/layout/EditorToolbar.vue
+++ b/apps/desktop/src/components/layout/EditorToolbar.vue
@@ -3,6 +3,7 @@ import { computed, nextTick, onUnmounted, ref, watch, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
import {
Play,
+ FastForward,
SquarePlay,
CirclePlay,
Loader2,
@@ -96,6 +97,7 @@ const props = defineProps<{
const emit = defineEmits<{
toolbarExecute: [source: "pointer" | "keyboard"];
+ toolbarExecuteAll: [source: "pointer" | "keyboard"];
toolbarExecuteInNewResultTab: [source: "pointer" | "keyboard"];
executePointerDown: [];
cancel: [];
@@ -331,6 +333,7 @@ function refreshObjectSource() {
}
const executeShortcutDisplay = computed(() => formatShortcutDisplay(settingsStore.editorSettings.shortcuts.executeSql));
const executeShortcutTooltip = computed(() => t("toolbar.executeShortcut", { shortcut: executeShortcutDisplay.value }));
+const executeAllShortcutTooltip = computed(() => formatShortcutTooltip(t("toolbar.executeAllSql"), settingsStore.editorSettings.shortcuts.executeAllSql));
const executeInNewResultTabTooltip = computed(() => formatShortcutTooltip(t("settings.shortcutExecuteSqlInNewResultTab"), settingsStore.editorSettings.shortcuts.executeSqlInNewResultTab));
// executableSql 在无选区时可能是整篇文档;只要有 DML 语句出现就显示预览按钮,
// 具体"当前语句"由编辑器(QueryEditor)按执行模式解析。
@@ -406,6 +409,9 @@ const executeButtonClass = computed(() => {
if (props.activeTab.isExecuting) return "";
return activeProductionContext.value.active ? "bg-red-500/10 text-red-700 hover:bg-red-500/20 hover:text-red-800 dark:text-red-300 dark:hover:text-red-200" : "bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/20 hover:text-emerald-800 dark:text-emerald-300 dark:hover:text-emerald-200";
});
+const executeAllButtonClass = computed(() => {
+ return activeProductionContext.value.active ? "text-red-700 hover:bg-red-500/10 hover:text-red-800 dark:text-red-300 dark:hover:text-red-200" : "text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-700 dark:text-emerald-300 dark:hover:text-emerald-200";
+});
const canMultiExecute = computed(() => {
if (!supportsQueryExecution(props.activeConnection?.db_type)) return false;
@@ -551,6 +557,10 @@ function onExecuteClick(event: MouseEvent) {
emit("toolbarExecute", event.detail > 0 ? "pointer" : "keyboard");
}
+function onExecuteAllClick(event: MouseEvent) {
+ emit("toolbarExecuteAll", event.detail > 0 ? "pointer" : "keyboard");
+}
+
function onExecuteInNewResultTabClick(event: MouseEvent) {
emit("toolbarExecuteInNewResultTab", event.detail > 0 ? "pointer" : "keyboard");
}
@@ -608,6 +618,14 @@ defineExpose({
</TooltipTrigger>
<TooltipContent>{{ activeTab.isExecuting ? t("toolbar.stopQuery") : executeShortcutTooltip }}</TooltipContent>
</Tooltip>
+ <Tooltip>
+ <TooltipTrigger as-child>
+ <Button variant="ghost" size="icon" class="h-6 w-6" :class="executeAllButtonClass" :disabled="activeTab.isExecuting || activeTab.isCancelling || activeTab.isExplaining || !activeTab.sql.trim()" :aria-label="t('toolbar.executeAllSql')" @click="onExecuteAllClick">
+ <FastForward class="h-3.5 w-3.5" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>{{ executeAllShortcutTooltip }}</TooltipContent>
+ </Tooltip>
<Tooltip>
<TooltipTrigger as-child>
<Button
diff --git a/apps/desktop/src/components/layout/QueryEditorSurface.vue b/apps/desktop/src/components/layout/QueryEditorSurface.vue
index b8f513efb8..dbfd959e0c 100644
--- a/apps/desktop/src/components/layout/QueryEditorSurface.vue
+++ b/apps/desktop/src/components/layout/QueryEditorSurface.vue
@@ -34,6 +34,7 @@ defineExpose<QueryEditorSurfaceHandle>({
refreshQueryEditorCompletionCache: () => contentAreaRef.value?.refreshQueryEditorCompletionCache() ?? false,
handleModRTarget: (target: Element) => contentAreaRef.value?.handleModRTarget(target) ?? false,
requestQueryEditorExecute: () => contentAreaRef.value?.requestQueryEditorExecute() ?? false,
+ requestQueryEditorExecuteAll: () => contentAreaRef.value?.requestQueryEditorExecuteAll() ?? false,
captureQueryEditorExecutionSnapshot: () => contentAreaRef.value?.captureQueryEditorExecutionSnapshot(),
requestQueryEditorExecuteInNewResultTab: () => contentAreaRef.value?.requestQueryEditorExecuteInNewResultTab() ?? false,
requestQueryEditorPreviewChanges: (stackSql?: string) => Promise.resolve(contentAreaRef.value?.requestQueryEditorPreviewChanges(stackSql) ?? false),
diff --git a/apps/desktop/src/components/layout/SqlEditorWorkspace.vue b/apps/desktop/src/components/layout/SqlEditorWorkspace.vue
index 1b0d19da7e..de9fc9f6bb 100644
--- a/apps/desktop/src/components/layout/SqlEditorWorkspace.vue
+++ b/apps/desktop/src/components/layout/SqlEditorWorkspace.vue
@@ -103,6 +103,7 @@ defineExpose({
return group?.handleModRTarget(target) ?? false;
},
requestQueryEditorExecute: (tabId?: string) => editorGroupForTab(tabId)?.requestQueryEditorExecute() ?? false,
+ requestQueryEditorExecuteAll: (tabId?: string) => editorGroupForTab(tabId)?.requestQueryEditorExecuteAll() ?? false,
captureQueryEditorExecutionSnapshot: (tabId?: string) => editorGroupForTab(tabId)?.captureQueryEditorExecutionSnapshot(),
requestQueryEditorExecuteInNewResultTab: (tabId?: string) => editorGroupForTab(tabId)?.requestQueryEditorExecuteInNewResultTab() ?? false,
requestQueryEditorPreviewChanges: (stackSql?: string) => activeEditorGroup()?.requestQueryEditorPreviewChanges(stackSql) ?? false,
diff --git a/apps/desktop/src/components/layout/__tests__/EditorGroup.mount.spec.ts b/apps/desktop/src/components/layout/__tests__/EditorGroup.mount.spec.ts
index e347d5858e..634c7f1bdb 100644
--- a/apps/desktop/src/components/layout/__tests__/EditorGroup.mount.spec.ts
+++ b/apps/desktop/src/components/layout/__tests__/EditorGroup.mount.spec.ts
@@ -202,6 +202,7 @@ describe("EditorGroup mount contract", () => {
...createNoopEditorToolbarActions(),
captureExecutionSnapshot: vi.fn(),
toolbarExecute: vi.fn(),
+ toolbarExecuteAll: vi.fn(),
toolbarExecuteInNewResultTab: vi.fn(),
cancelExecution: vi.fn(),
explain: vi.fn(),
@@ -238,6 +239,7 @@ describe("EditorGroup mount contract", () => {
// Toolbar events flow to the injected actions with the group's tab id.
(toolbar as any).__vueParentComponent.emit("executePointerDown");
(toolbar as any).__vueParentComponent.emit("toolbarExecute", "pointer");
+ (toolbar as any).__vueParentComponent.emit("toolbarExecuteAll", "pointer");
(toolbar as any).__vueParentComponent.emit("toolbarExecuteInNewResultTab", "pointer");
(toolbar as any).__vueParentComponent.emit("cancel");
(toolbar as any).__vueParentComponent.emit("explain");
@@ -248,6 +250,7 @@ describe("EditorGroup mount contract", () => {
await nextTick();
expect(actions.captureExecutionSnapshot).toHaveBeenCalledWith(queryId);
expect(actions.toolbarExecute).toHaveBeenCalledWith("pointer", queryId);
+ expect(actions.toolbarExecuteAll).toHaveBeenCalledWith("pointer", queryId);
expect(actions.toolbarExecuteInNewResultTab).toHaveBeenCalledWith("pointer", queryId);
expect(actions.cancelExecution).toHaveBeenCalledWith(queryId);
expect(actions.explain).toHaveBeenCalledWith(queryId);
diff --git a/apps/desktop/src/components/layout/__tests__/EditorToolbar.mount.spec.ts b/apps/desktop/src/components/layout/__tests__/EditorToolbar.mount.spec.ts
index 93c85684e1..929d61e223 100644
--- a/apps/desktop/src/components/layout/__tests__/EditorToolbar.mount.spec.ts
+++ b/apps/desktop/src/components/layout/__tests__/EditorToolbar.mount.spec.ts
@@ -145,6 +145,61 @@ describe("EditorToolbar mount contract", () => {
host.remove();
});
+ it("emits toolbarExecuteAll when clicking the execute all button", async () => {
+ const connectionStore = useConnectionStore();
+ connectionStore.connections = [
+ {
+ id: "conn-1",
+ name: "conn",
+ db_type: "mysql",
+ color: "",
+ } as never,
+ ];
+
+ const host = createHost();
+ const onToolbarExecuteAll = vi.fn();
+ const app = createApp(EditorToolbar, {
+ activeTab: {
+ id: "tab-1",
+ title: "SQL",
+ connectionId: "conn-1",
+ database: "db",
+ sql: "SELECT 1;\nSELECT 2;",
+ mode: "query",
+ isExecuting: false,
+ isCancelling: false,
+ isExplaining: false,
+ },
+ activeConnection: connectionStore.getConfig("conn-1"),
+ executableSql: "SELECT 1",
+ explainMode: "explain",
+ blockDangerousRedisCommands: false,
+ sqlKeywordCase: "preserve",
+ databaseRequiredSignal: 0,
+ autoCommit: true,
+ txnSessionId: undefined,
+ txnAutoRolledBack: false,
+ txnPossiblyDirty: false,
+ stickyProvenReadOnlyState: false,
+ onToolbarExecuteAll,
+ });
+ app.use(pinia);
+ app.use(i18n);
+ app.mount(host);
+ await nextTick();
+
+ const executeAllButton = host.querySelector<HTMLButtonElement>('button[aria-label="toolbar.executeAllSql"]');
+ expect(executeAllButton).not.toBeNull();
+ executeAllButton!.dispatchEvent(new MouseEvent("click", { detail: 1, bubbles: true }));
+ await nextTick();
+
+ expect(onToolbarExecuteAll).toHaveBeenCalledTimes(1);
+ expect(onToolbarExecuteAll.mock.calls[0]?.[0]).toBe("pointer");
+
+ app.unmount();
+ host.remove();
+ });
+
it("keeps the manually selected SQL from pointer-down through toolbar execution", async () => {
const connectionStore = useConnectionStore();
connectionStore.connections = [
diff --git a/apps/desktop/src/components/layout/__tests__/SqlEditorWorkspace.mount.spec.ts b/apps/desktop/src/components/layout/__tests__/SqlEditorWorkspace.mount.spec.ts
index 60bd953b89..342c759979 100644
--- a/apps/desktop/src/components/layout/__tests__/SqlEditorWorkspace.mount.spec.ts
+++ b/apps/desktop/src/components/layout/__tests__/SqlEditorWorkspace.mount.spec.ts
@@ -63,6 +63,10 @@ vi.mock("@/components/layout/EditorGroup.vue", () => ({
groupExecutionCalls.request.push(this.groupId);
return true;
},
+ requestQueryEditorExecuteAll(this: { groupId: string }) {
+ groupExecutionCalls.request.push(`all:${this.groupId}`);
+ return true;
+ },
},
template: `<div data-test="editor-group" :data-group-id="groupId" :data-tab-ids="tabIds.join(',')" :data-active-tab-id="activeTabId" :data-content-suppressed="contentSuppressed ? 'true' : 'false'"><button data-test="emit-execute" @click="$emit('execute', { fullSql: 'SELECT 1', selectedSql: 'SELECT 1', cursorPos: 0, selectionFrom: 0, selectionTo: 8 })">execute</button></div>`,
},
@@ -210,6 +214,7 @@ describe("SqlEditorWorkspace mount contract", () => {
const vm = app.mount(host) as unknown as {
captureQueryEditorExecutionSnapshot: (tabId?: string) => { selectedSql: string } | undefined;
requestQueryEditorExecute: (tabId?: string) => boolean;
+ requestQueryEditorExecuteAll: (tabId?: string) => boolean;
};
await nextTick();
@@ -217,7 +222,8 @@ describe("SqlEditorWorkspace mount contract", () => {
expect(snapshot?.selectedSql).toBe("SELECT g2");
expect(groupExecutionCalls.capture).toEqual(["g2"]);
expect(vm.requestQueryEditorExecute("tab-b")).toBe(true);
- expect(groupExecutionCalls.request).toEqual(["g2"]);
+ expect(vm.requestQueryEditorExecuteAll("tab-b")).toBe(true);
+ expect(groupExecutionCalls.request).toEqual(["g2", "all:g2"]);
app.unmount();
host.remove();
diff --git a/apps/desktop/src/components/layout/editorToolbarActions.ts b/apps/desktop/src/components/layout/editorToolbarActions.ts
index 6bcaafefac..dfa6eefbaa 100644
--- a/apps/desktop/src/components/layout/editorToolbarActions.ts
+++ b/apps/desktop/src/components/layout/editorToolbarActions.ts
@@ -32,6 +32,7 @@ export interface EditorToolbarActions {
/** Captures the acting editor's execution snapshot before a toolbar click. */
captureExecutionSnapshot(tabId: string): void;
toolbarExecute(source: "pointer" | "keyboard", tabId: string): void;
+ toolbarExecuteAll(source: "pointer" | "keyboard", tabId: string): void;
toolbarExecuteInNewResultTab(source: "pointer" | "keyboard", tabId: string): void;
cancelExecution(tabId: string): void;
explain(tabId: string): void;
@@ -85,6 +86,7 @@ export function createNoopEditorToolbarActions(): EditorToolbarActions {
connectionRequiredSignalFor: () => 0,
captureExecutionSnapshot: noop,
toolbarExecute: noop,
+ toolbarExecuteAll: noop,
toolbarExecuteInNewResultTab: noop,
cancelExecution: noop,
explain: noop,
diff --git a/apps/desktop/src/components/layout/querySurfaces.ts b/apps/desktop/src/components/layout/querySurfaces.ts
index 7567d8c207..f31ca878f8 100644
--- a/apps/desktop/src/components/layout/querySurfaces.ts
+++ b/apps/desktop/src/components/layout/querySurfaces.ts
@@ -22,6 +22,7 @@ export interface QueryEditorSurfaceHandle {
refreshQueryEditorCompletionCache(): boolean;
handleModRTarget(target: Element): boolean;
requestQueryEditorExecute(): boolean;
+ requestQueryEditorExecuteAll(): boolean;
captureQueryEditorExecutionSnapshot(): SqlExecutionSnapshot | undefined;
requestQueryEditorExecuteInNewResultTab(): boolean;
requestQueryEditorPreviewChanges(stackSql?: string): Promise<boolean>;
diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTabLifecycle.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTabLifecycle.spec.ts
index 432c31f2d0..84c2518cab 100644
--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTabLifecycle.spec.ts
+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTabLifecycle.spec.ts
@@ -1,4 +1,4 @@
-// @vitest-environment happy-dom
+// @vitest-environment happy-dom
import { createApp, nextTick, reactive, ref, type App } from "vue";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -269,13 +269,19 @@ describe("TableStructureEditor DDL tab lifecycle", () => {
app.mount(root);
const content = () => root.querySelector(".cm-content")?.textContent ?? "";
const toggle = () => root.querySelector<HTMLButtonElement>('[role="switch"]')!;
- await vi.waitFor(() => expect(content()).toMatch(/PARTITION BY\s+HASH/), { timeout: 5000 });
+ await vi.waitFor(
+ () => {
+ expect(content()).toMatch(/PARTITION BY\s+HASH/);
+ expect(root.querySelector('[role="switch"]')).not.toBeNull();
+ },
+ { timeout: 5000 },
+ );
expect(content()).not.toContain("PCTFREE");
expect(toggle().getAttribute("aria-checked")).toBe("true");
toggle().click();
- await vi.waitFor(() => expect(content()).toContain("PCTFREE"));
+ await vi.waitFor(() => expect(content()).toContain("PCTFREE"), { timeout: 5000 });
buttonWithText(root, "grid.copyDdl").click();
- await vi.waitFor(() => expect(mocks.copyToClipboard).toHaveBeenLastCalledWith(content()));
+ await vi.waitFor(() => expect(mocks.copyToClipboard).toHaveBeenLastCalledWith(content()), { timeout: 5000 });
const { EditorView } = await import("@codemirror/view");
const view = EditorView.findFromDOM(root.querySelector(".cm-content")!)!;
view.dispatch({ changes: { from: view.state.doc.length, insert: "\n-- local edit" } });
@@ -286,7 +292,7 @@ describe("TableStructureEditor DDL tab lifecycle", () => {
expect(content()).toContain("PCTFREE");
expect(content()).toContain("-- local edit");
buttonWithText(root, "structureEditor.resetDdl").click();
- await vi.waitFor(() => expect(content()).not.toContain("PCTFREE"));
+ await vi.waitFor(() => expect(content()).not.toContain("PCTFREE"), { timeout: 5000 });
expect(content()).not.toContain("-- local edit");
expect(mocks.loadObjectDdl).toHaveBeenCalledTimes(1);
});
@@ -319,7 +325,7 @@ describe("TableStructureEditor DDL tab lifecycle", () => {
selectTab(buttonWithText(root, "DDL"));
await nextTick();
- await vi.waitFor(() => expect(root.querySelector(".cm-content")?.textContent).toContain(DDL), { timeout: 1000 });
+ await vi.waitFor(() => expect(root.querySelector(".cm-content")?.textContent).toContain(DDL), { timeout: 5000 });
expect(mocks.loadObjectDdl).toHaveBeenCalledTimes(1);
});
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index be405dadf9..13a6ccd48a 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -771,6 +771,7 @@ export default {
newConnection: "New Connection",
newQuery: "New Query",
executeShortcut: "Execute selection/query ({shortcut})",
+ executeAllSql: "Execute all SQL",
stopQuery: "Stop query",
explainPlan: "Explain plan",
stopExplain: "Stop explain",
@@ -9989,6 +9990,7 @@ export default {
queryResultExportFileNameSourceTabTitle: "Query tab title (SQL file name)",
performanceSection: "Performance",
shortcutExecuteSql: "Execute SQL",
+ shortcutExecuteAllSql: "Execute all SQL",
shortcutExecuteSqlInNewResultTab: "Execute SQL in new result tab",
shortcutFind: "Find",
shortcutGotoLine: "Go to Line",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 23c18422b9..db273bab2e 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -676,6 +676,7 @@ export default withEnglishFallback({
alwaysOnTopOff: "No mantener encima",
blockDangerousRedisCommands: "Bloquear comandos peligrosos",
multiDbExecute: "Ejecución multi-base de datos",
+ executeAllSql: "Ejecutar todo el SQL",
},
multiDbExecute: {
manualTransaction: "Transacción manual",
@@ -9589,6 +9590,7 @@ export default withEnglishFallback({
tabGroupRowsSingle: "Una fila",
tabGroupRowsTwoRow: "Dos filas (grupos en su propia fila)",
tabGroupRowsDescription: "Solo se aplica a una barra de pestañas superior o inferior con la agrupación activada: los grupos ocupan su propia fila y las pestañas del grupo seleccionado aparecen en la fila siguiente.",
+ shortcutExecuteAllSql: "Ejecutar todo el SQL",
},
driverStore: {
jreDirRemoveFailed: "No se pudo eliminar el directorio JRE antiguo: {path} (error original: {error})",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 935e8242d4..1806f82354 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -666,6 +666,7 @@ export default withEnglishFallback({
alwaysOnTopOff: "Non mantenere in primo piano",
blockDangerousRedisCommands: "Blocca comandi pericolosi",
multiDbExecute: "Esecuzione multi-DB",
+ executeAllSql: "Esegui tutto il SQL",
},
multiDbExecute: {
manualTransaction: "Transazione manuale",
@@ -9338,6 +9339,7 @@ export default withEnglishFallback({
tabGroupRowsSingle: "Riga singola",
tabGroupRowsTwoRow: "Due righe (gruppi su una riga dedicata)",
tabGroupRowsDescription: "Si applica solo a una barra delle schede superiore o inferiore con raggruppamento attivo: i gruppi occupano una riga dedicata e le schede del gruppo selezionato compaiono nella riga successiva.",
+ shortcutExecuteAllSql: "Esegui tutto il SQL",
},
driverStore: {
jreDirRemoveFailed: "Impossibile rimuovere la vecchia directory JRE: {path} (errore originale: {error})",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index a88ab168bb..82aa003a9c 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -667,6 +667,7 @@ export default withEnglishFallback({
alwaysOnTopOff: "手前表示を解除",
blockDangerousRedisCommands: "危険なコマンドをブロック",
multiDbExecute: "複数DB実行",
+ executeAllSql: "すべての SQL を実行",
},
multiDbExecute: {
manualTransaction: "手動トランザクション",
@@ -9375,6 +9376,7 @@ export default withEnglishFallback({
tabGroupRowsSingle: "1行",
tabGroupRowsTwoRow: "2行(グループを独立した行に表示)",
tabGroupRowsDescription: "タブバーが上または下に配置されていて、グループ化が有効な場合にのみ適用されます。グループは専用の行に表示され、選択したグループのタブは次の行に表示されます。",
+ shortcutExecuteAllSql: "すべての SQL を実行",
},
driverStore: {
jreDirRemoveFailed: "古い JRE ディレクトリを削除できませんでした: {path}(元のエラー: {error})",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 4a0dba611e..6e957bcecd 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -673,6 +673,7 @@ export default withEnglishFallback({
blockDangerousRedisCommands: "위험한 명령 차단",
saveSqlFile: "원본 파일에 저장",
pluginCenter: "플러그인 센터",
+ executeAllSql: "모든 SQL 실행",
},
multiDbExecute: {
manualTransaction: "수동 트랜잭션",
@@ -9278,6 +9279,7 @@ export default withEnglishFallback({
tabGroupRowsSingle: "한 줄",
tabGroupRowsTwoRow: "두 줄 (그룹을 별도 줄에 표시)",
tabGroupRowsDescription: "탭 표시줄이 위쪽 또는 아래쪽에 있고 그룹화가 활성화된 경우에만 적용됩니다. 그룹은 별도의 줄에 표시되고 선택한 그룹의 탭은 다음 줄에 표시됩니다.",
+ shortcutExecuteAllSql: "모든 SQL 실행",
},
driverStore: {
jreDirRemoveFailed: "이전 JRE 디렉터리 제거 실패: {path} (원래 오류: {error})",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 5d21a67da1..1453abbc68 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -667,6 +667,7 @@ export default withEnglishFallback({
alwaysOnTopOff: "Não manter no topo",
blockDangerousRedisCommands: "Bloquear comandos perigosos",
multiDbExecute: "Execução em múltiplos bancos",
+ executeAllSql: "Executar todo o SQL",
},
multiDbExecute: {
manualTransaction: "Transação manual",
@@ -9335,6 +9336,7 @@ export default withEnglishFallback({
tabGroupRowsSingle: "Uma linha",
tabGroupRowsTwoRow: "Duas linhas (grupos em linha própria)",
tabGroupRowsDescription: "Aplica-se apenas a uma barra de abas no topo ou na base com agrupamento ativado: os grupos ocupam uma linha própria e as abas do grupo selecionado aparecem na linha seguinte.",
+ shortcutExecuteAllSql: "Executar todo o SQL",
},
driverStore: {
jreDirRemoveFailed: "Não foi possível remover o diretório JRE antigo: {path} (erro original: {error})",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index e7f5981d38..d67fab95eb 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -647,6 +647,7 @@ export default withEnglishFallback({
alwaysOnTopOff: "Не оставлять поверх других окон",
blockDangerousRedisCommands: "Блокировать опасные команды",
multiDbExecute: "Выполнение на нескольких БД",
+ executeAllSql: "Выполнить весь SQL",
},
multiDbExecute: {
manualTransaction: "Ручная транзакция",
@@ -10766,6 +10767,7 @@ export default withEnglishFallback({
tabGroupRowsSingle: "Одна строка",
tabGroupRowsTwoRow: "Две строки (группы на отдельной строке)",
tabGroupRowsDescription: "Действует только для верхней или нижней панели вкладок с включённой группировкой: группы занимают отдельную строку, а вкладки выбранной группы отображаются на следующей строке.",
+ shortcutExecuteAllSql: "Выполнить весь SQL",
},
driverStore: {
jreDirRemoveFailed: "Не удалось удалить старый каталог JRE: {path} (исходная ошибка: {error})",
diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.ts
index ba379e83cd..56b0ed8d49 100644
--- a/apps/desktop/src/i18n/locales/th.ts
+++ b/apps/desktop/src/i18n/locales/th.ts
@@ -794,6 +794,7 @@ export default withEnglishFallback({
alwaysOnTopOff: "ไม่ให้อยู่ด้านบน",
blockDangerousRedisCommands: "บล็อกคำสั่งที่มีความเสี่ยง",
multiDbExecute: "การเรียกใช้หลายฐานข้อมูล",
+ executeAllSql: "เรียกใช้ SQL ทั้งหมด",
},
multiDbExecute: {
manualTransaction: "Transaction แบบ Manual",
@@ -11184,6 +11185,7 @@ export default withEnglishFallback({
tabGroupRowsSingle: "แถวเดียว",
tabGroupRowsTwoRow: "สองแถว (กลุ่มแสดงในแถวของตัวเอง)",
tabGroupRowsDescription: "ใช้เฉพาะเมื่อแถบแท็บอยู่ด้านบนหรือด้านล่างและเปิดใช้งานการจัดกลุ่ม: กลุ่มจะแสดงในแถวของตัวเอง และแท็บของกลุ่มที่เลือกจะแสดงในแถวถัดไป",
+ shortcutExecuteAllSql: "เรียกใช้ SQL ทั้งหมด",
},
driverStore: {
jreDirRemoveFailed: "ลบไดเรกทอรี JRE เก่าไม่สำเร็จ: {path} (ข้อผิดพลาดเดิม: {error})",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 0c61c79132..4f2599d8b7 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -707,6 +707,7 @@ export default withEnglishFallback({
newConnection: "新建连接",
newQuery: "新建查询",
executeShortcut: "执行选中/全部 ({shortcut})",
+ executeAllSql: "执行全部 SQL",
stopQuery: "停止执行",
explainPlan: "执行计划",
stopExplain: "停止执行计划",
@@ -9952,6 +9953,7 @@ export default withEnglishFallback({
queryResultExportFileNameSourceTabTitle: "查询页签名(SQL 文件名)",
performanceSection: "性能",
shortcutExecuteSql: "执行 SQL",
+ shortcutExecuteAllSql: "执行全部 SQL",
shortcutExecuteSqlInNewResultTab: "在新结果标签页中执行 SQL",
shortcutFind: "查找",
shortcutGotoLine: "跳转到行",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 5e1b60c168..abe23139ed 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -618,6 +618,7 @@ export default withEnglishFallback({
newConnection: "建立連線",
newQuery: "建立查詢",
executeShortcut: "執行選取/全部 ({shortcut})",
+ executeAllSql: "執行全部 SQL",
stopQuery: "停止執行",
explainPlan: "執行計畫",
stopExplain: "停止執行計畫",
@@ -7997,6 +7998,7 @@ export default withEnglishFallback({
redisDatabaseDisplayLimitDescription: "僅作用於 Redis 連線:側邊欄一次最多顯示的資料庫數量,超出部分可透過「載入更多」查看。",
redisDatabaseDisplayLimitOption: "{count} 個資料庫",
shortcutExecuteSql: "執行 SQL",
+ shortcutExecuteAllSql: "執行全部 SQL",
shortcutExecuteSqlInNewResultTab: "在新結果分頁中執行 SQL",
shortcutFind: "尋找",
shortcutGotoLine: "跳至行",
diff --git a/apps/desktop/src/lib/__tests__/editor/queryEditorExecutionShortcut.spec.ts b/apps/desktop/src/lib/__tests__/editor/queryEditorExecutionShortcut.spec.ts
index d8f29c4dee..579a4e45bd 100644
--- a/apps/desktop/src/lib/__tests__/editor/queryEditorExecutionShortcut.spec.ts
+++ b/apps/desktop/src/lib/__tests__/editor/queryEditorExecutionShortcut.spec.ts
@@ -109,6 +109,7 @@ describe("QueryEditor execution shortcuts", () => {
describe("createQueryEditorExecutionShortcutHandler", () => {
const shortcuts = {
executeSql: "Mod+Enter",
+ executeAllSql: "Alt+X",
executeSqlInNewResultTab: "Mod+\\",
explainSql: "Mod+E",
};
@@ -143,6 +144,37 @@ describe("QueryEditor execution shortcuts", () => {
expect(stopPropagation).toHaveBeenCalled();
});
+ it("suppresses execute all SQL shortcut when event.repeat is true or executing", () => {
+ const handler = createQueryEditorExecutionShortcutHandler({
+ getShortcuts: () => shortcuts,
+ isExecuting: () => false,
+ });
+
+ const repeatEvent = new KeyboardEvent("keydown", {
+ key: "x",
+ code: "KeyX",
+ altKey: true,
+ repeat: true,
+ bubbles: true,
+ cancelable: true,
+ });
+ expect(handler(repeatEvent)).toBe(true);
+
+ const executingHandler = createQueryEditorExecutionShortcutHandler({
+ getShortcuts: () => shortcuts,
+ isExecuting: () => true,
+ });
+ const executingEvent = new KeyboardEvent("keydown", {
+ key: "x",
+ code: "KeyX",
+ altKey: true,
+ repeat: false,
+ bubbles: true,
+ cancelable: true,
+ });
+ expect(executingHandler(executingEvent)).toBe(true);
+ });
+
it("suppresses execution shortcuts when isExecuting is true", () => {
const handler = createQueryEditorExecutionShortcutHandler({
getShortcuts: () => shortcuts,
diff --git a/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts b/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts
index f3a7f62402..1355e0745c 100644
--- a/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts
+++ b/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts
@@ -169,6 +169,17 @@ describe("shortcutRegistry editor actions", () => {
expect(formatShortcut(DEFAULT_SHORTCUT_SETTINGS.openDataInNewTab, "MacIntel")).toBe("Alt");
});
+ it("registers a conflict-free DBeaver-style shortcut for executing all SQL", () => {
+ const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "executeAllSql");
+
+ expect(definition).toMatchObject({ scope: "editor", defaultShortcut: "Alt+X" });
+ expect(DEFAULT_SHORTCUT_SETTINGS.executeAllSql).toBe("Alt+X");
+ expect(formatShortcut(DEFAULT_SHORTCUT_SETTINGS.executeAllSql, "MacIntel")).toBe("Alt+X");
+ expect(formatShortcut(DEFAULT_SHORTCUT_SETTINGS.executeAllSql, "Win32")).toBe("Alt+X");
+ expect(shortcutToCodeMirrorKey(DEFAULT_SHORTCUT_SETTINGS.executeAllSql)).toBe("Alt-x");
+ expect(findShortcutConflict("executeAllSql", DEFAULT_SHORTCUT_SETTINGS.executeAllSql, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();
+ });
+
it("registers a conflict-free DBeaver-style shortcut for executing in a new result tab", () => {
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "executeSqlInNewResultTab");
diff --git a/apps/desktop/src/lib/editor/keyboardShortcuts.ts b/apps/desktop/src/lib/editor/keyboardShortcuts.ts
index 98490bfd86..299e3a303b 100644
--- a/apps/desktop/src/lib/editor/keyboardShortcuts.ts
+++ b/apps/desktop/src/lib/editor/keyboardShortcuts.ts
@@ -176,6 +176,10 @@ export function isExecuteSqlShortcut(event: ShortcutLikeEvent, shortcuts?: Parti
return matchesShortcut(event, actionShortcut("executeSql", shortcuts));
}
+export function isExecuteAllSqlShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
+ return matchesShortcut(event, actionShortcut("executeAllSql", shortcuts));
+}
+
export function isExecuteSqlInNewResultTabShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
return matchesShortcut(event, actionShortcut("executeSqlInNewResultTab", shortcuts));
}
diff --git a/apps/desktop/src/lib/editor/queryEditorExecutionShortcut.ts b/apps/desktop/src/lib/editor/queryEditorExecutionShortcut.ts
index db1c315459..c8689e24bf 100644
--- a/apps/desktop/src/lib/editor/queryEditorExecutionShortcut.ts
+++ b/apps/desktop/src/lib/editor/queryEditorExecutionShortcut.ts
@@ -1,6 +1,6 @@
import type { Command, EditorView, KeyBinding } from "@codemirror/view";
import { shortcutToCodeMirrorKey, type ShortcutSettings } from "@/lib/editor/shortcutRegistry";
-import { isExecuteSqlShortcut, isExecuteSqlInNewResultTabShortcut, isExplainSqlShortcut } from "@/lib/editor/keyboardShortcuts";
+import { isExecuteSqlShortcut, isExecuteAllSqlShortcut, isExecuteSqlInNewResultTabShortcut, isExplainSqlShortcut } from "@/lib/editor/keyboardShortcuts";
const SAFARI_POST_COMPOSITION_KEY_WINDOW_MS = 100;
@@ -82,7 +82,7 @@ export function createQueryEditorExecutionShortcutHandler(options: { getShortcut
return (event: KeyboardEvent) => {
if (!event.repeat && !options.isExecuting?.()) return false;
const shortcuts = options.getShortcuts();
- const isExecution = isExecuteSqlShortcut(event, shortcuts) || isExecuteSqlInNewResultTabShortcut(event, shortcuts) || (options.enableExplainShortcut?.() && isExplainSqlShortcut(event, shortcuts));
+ const isExecution = isExecuteSqlShortcut(event, shortcuts) || isExecuteAllSqlShortcut(event, shortcuts) || isExecuteSqlInNewResultTabShortcut(event, shortcuts) || (options.enableExplainShortcut?.() && isExplainSqlShortcut(event, shortcuts));
if (!isExecution) return false;
event.preventDefault();
event.stopPropagation();
diff --git a/apps/desktop/src/lib/editor/shortcutRegistry.ts b/apps/desktop/src/lib/editor/shortcutRegistry.ts
index f8017e2cba..d7113e4f6d 100644
--- a/apps/desktop/src/lib/editor/shortcutRegistry.ts
+++ b/apps/desktop/src/lib/editor/shortcutRegistry.ts
@@ -3,6 +3,7 @@ import { isModifierDoubleTapShortcut, matchesModifierDoubleTapShortcut } from "@
export type ShortcutActionId =
| "executeSql"
+ | "executeAllSql"
| "executeSqlInNewResultTab"
| "explainSql"
| "formatSql"
@@ -207,6 +208,12 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
scope: "editor",
defaultShortcut: "Mod+Enter",
},
+ {
+ id: "executeAllSql",
+ labelKey: "settings.shortcutExecuteAllSql",
+ scope: "editor",
+ defaultShortcut: "Alt+X",
+ },
{
id: "executeSqlInNewResultTab",
labelKey: "settings.shortcutExecuteSqlInNewResultTab",