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。

fix(editor): respect configured SQL execution mode

t8y2990be3c32985
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index e595e13e1c..1e4c177c72 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -447,7 +447,6 @@ function handleTab(view: EditorViewType): boolean {
}
interface RequestExecuteOptions {
- forceCurrent?: boolean;
ignoreSelection?: boolean;
}
@@ -472,11 +471,6 @@ function requestExecuteFromView(currentView: EditorViewType, cursorPos: number,
const doc = currentView.state.doc.toString();
const candidates = buildExecutionCandidates(doc, cursorPos, props.databaseType);
if (candidates.length === 0) return false;
- if (options.forceCurrent) {
- const candidate = candidates.find((item) => item.kind === "cursor") ?? candidates[0];
- emit("execute", candidate.sql);
- return true;
- }
if (!settingsStore.editorSettings.showExecutionTargetPicker || !hasMultipleExecutionTargets(doc, props.databaseType)) {
const preferredKind = settingsStore.editorSettings.executeMode === "current" ? "cursor" : "all";
const candidate = candidates.find((item) => item.kind === preferredKind) ?? candidates[0];
@@ -1148,7 +1142,8 @@ function runKeymapExtension(codeMirrorKeymap: (typeof import("@codemirror/view")
const shortcuts = normalizeShortcutSettings(settingsStore.editorSettings.shortcuts);
const Prec = codeMirrorPrec;
const binding = (shortcut: string, run: (view: EditorViewType) => boolean) => (shortcut ? [{ key: shortcutToCodeMirrorKey(shortcut), preventDefault: true, run }] : []);
- const executeBindings = props.hideExecutionControls ? [] : binding(shortcuts.executeSql, () => requestExecute({ forceCurrent: true }));
+ // Keep the shortcut on the shared path so selection, picker, and execute-mode behavior stay aligned with other execution entry points.
+ const executeBindings = props.hideExecutionControls ? [] : binding(shortcuts.executeSql, () => requestExecute());
return [
Prec?.high(
codeMirrorKeymap.of([
diff --git a/apps/desktop/src/lib/__tests__/editor/queryEditorExecution.spec.ts b/apps/desktop/src/lib/__tests__/editor/queryEditorExecution.spec.ts
new file mode 100644
index 0000000000..8d8b1af917
--- /dev/null
+++ b/apps/desktop/src/lib/__tests__/editor/queryEditorExecution.spec.ts
@@ -0,0 +1,19 @@
+import { readFileSync } from "node:fs";
+import { describe, expect, it } from "vitest";
+
+const queryEditorSource = readFileSync(new URL("../../../components/editor/QueryEditor.vue", import.meta.url), "utf8");
+
+describe("QueryEditor execution routing", () => {
+ it("routes the execution shortcut through the shared execution-mode contract", () => {
+ expect(queryEditorSource).toContain("binding(shortcuts.executeSql, () => requestExecute())");
+ expect(queryEditorSource).not.toContain("forceCurrent");
+ });
+
+ it("keeps selection priority and the configured current/all target choice", () => {
+ const selectionBranch = queryEditorSource.indexOf("if (!options.ignoreSelection && !selection.empty)");
+ const executeModeBranch = queryEditorSource.indexOf('settingsStore.editorSettings.executeMode === "current" ? "cursor" : "all"');
+
+ expect(selectionBranch).toBeGreaterThan(-1);
+ expect(executeModeBranch).toBeGreaterThan(selectionBranch);
+ });
+});