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 ignore action to sql parameter dialog

zipgd7941572b803
diff --git a/apps/desktop/src/components/editor/SqlParameterDialog.vue b/apps/desktop/src/components/editor/SqlParameterDialog.vue
index 8b57c3fe32..3e57e9b538 100644
--- a/apps/desktop/src/components/editor/SqlParameterDialog.vue
+++ b/apps/desktop/src/components/editor/SqlParameterDialog.vue
@@ -96,6 +96,11 @@ function clearParameterValues() {
values.value = next;
}
+function ignoreParameters() {
+ open.value = false;
+ emit("execute", props.sql);
+}
+
function updateValue(name: string, value: string) {
const matchedHistory = histories.value[name]?.find((entry) => entry.value === value);
values.value[name] = { ...(values.value[name] ?? { kind: "string" }), ...(matchedHistory ? { kind: matchedHistory.kind } : {}), value };
@@ -226,6 +231,9 @@ async function copyResolvedSql() {
</div>
<DialogFooter>
+ <Button type="button" variant="outline" data-testid="sql-parameters-ignore" @click="ignoreParameters">
+ {{ t("sqlParameters.ignore") }}
+ </Button>
<Button variant="outline" @click="open = false">{{ t("dangerDialog.cancel") }}</Button>
<Button variant="outline" @click="copyResolvedSql">
<Copy class="mr-1.5 h-4 w-4" />
diff --git a/apps/desktop/src/components/editor/__tests__/SqlParameterDialog.spec.ts b/apps/desktop/src/components/editor/__tests__/SqlParameterDialog.spec.ts
index 0c469a0f9b..de5fd96341 100644
--- a/apps/desktop/src/components/editor/__tests__/SqlParameterDialog.spec.ts
+++ b/apps/desktop/src/components/editor/__tests__/SqlParameterDialog.spec.ts
@@ -86,6 +86,10 @@ function clearActionButton(): HTMLButtonElement | null {
return document.body.querySelector('[data-testid="sql-parameters-clear-values"]');
}
+function ignoreActionButton(): HTMLButtonElement | null {
+ return document.body.querySelector('[data-testid="sql-parameters-ignore"]');
+}
+
function clickRawAction() {
const button = actionButton();
expect(button).not.toBeNull();
@@ -98,6 +102,12 @@ function clickClearAction() {
button!.click();
}
+function clickIgnoreAction() {
+ const button = ignoreActionButton();
+ expect(button).not.toBeNull();
+ button!.click();
+}
+
function buttonWithText(text: string): HTMLButtonElement | undefined {
return Array.from(document.body.querySelectorAll("button")).find((button) => button.textContent?.trim() === text);
}
@@ -183,6 +193,38 @@ describe("SqlParameterDialog raw parameter action", () => {
});
});
+describe("SqlParameterDialog ignore parameter action", () => {
+ it("closes the dialog and emits the original SQL without remembering or mutating values", async () => {
+ const { state, onExecute } = await mountDialog();
+
+ clickIgnoreAction();
+ await nextTick();
+
+ expect(state.open).toBe(false);
+ expect(onExecute).toHaveBeenCalledOnce();
+ expect(onExecute).toHaveBeenCalledWith(SQL);
+ expect(historyMocks.remember).not.toHaveBeenCalled();
+ expect(parameterInputs().map((input) => input.value)).toEqual(PARAMETERS.map((parameter) => MIXED_VALUES[parameter.key]?.value ?? ""));
+ });
+
+ it("does not apply current parameter edits when ignoring", async () => {
+ const { state, onExecute } = await mountDialog();
+
+ const firstInput = parameterInputs()[0];
+ expect(firstInput).not.toBeUndefined();
+ firstInput!.value = "changed";
+ firstInput!.dispatchEvent(new Event("input", { bubbles: true }));
+ await nextTick();
+
+ clickIgnoreAction();
+ await nextTick();
+
+ expect(state.open).toBe(false);
+ expect(onExecute).toHaveBeenCalledWith(SQL);
+ expect(historyMocks.remember).not.toHaveBeenCalled();
+ });
+});
+
describe("SqlParameterDialog clear parameter values action", () => {
it("clears every displayed value while preserving kinds and updating the preview", async () => {
const { state, onExecute } = await mountDialog();
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index b96dbbe2f6..07f2f7ffdd 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -5377,6 +5377,7 @@ export default {
execute: "Execute",
clearValues: "Clear Values",
useRawForAll: "Use Raw SQL for All",
+ ignore: "Ignore",
kind: {
string: "String",
number: "Number",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 8c1473fbb6..70be54f467 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -5105,6 +5105,7 @@ export default withEnglishFallback({
execute: "Ejecutar",
clearValues: "Borrar valores",
useRawForAll: "Usar SQL sin procesar para todos",
+ ignore: "Ignorar",
kind: {
string: "Cadena",
number: "Número",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 08425669e7..bb0023c3c0 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -5103,6 +5103,7 @@ export default withEnglishFallback({
execute: "Esegui",
clearValues: "Cancella valori",
useRawForAll: "Usa SQL non elaborato per tutti",
+ ignore: "Ignora",
kind: {
string: "Stringa",
number: "Numero",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 31f3553f7f..02b549daa5 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -5132,6 +5132,7 @@ export default withEnglishFallback({
execute: "実行",
clearValues: "値をクリア",
useRawForAll: "すべてを生の SQL に設定",
+ ignore: "無視",
kind: {
string: "文字列",
number: "数値",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index c283587477..16e6adef3b 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -4797,6 +4797,7 @@ export default withEnglishFallback({
execute: "실행",
clearValues: "값 지우기",
useRawForAll: "모두 원시 SQL로 설정",
+ ignore: "무시",
kind: {
string: "문자열",
number: "숫자",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 92a9914f4a..820fba3ffc 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -5105,6 +5105,7 @@ export default withEnglishFallback({
execute: "Executar",
clearValues: "Limpar valores",
useRawForAll: "Usar SQL bruto para todos",
+ ignore: "Ignorar",
kind: {
string: "Texto",
number: "Número",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 9ae5f02a7d..dba63887c0 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -5361,6 +5361,7 @@ export default withEnglishFallback({
execute: "执行",
clearValues: "清空参数值",
useRawForAll: "全部使用原始 SQL",
+ ignore: "忽略",
kind: {
string: "字符串",
number: "数字",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 3a7ae4b8bb..9d1bdb5be8 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -4428,6 +4428,7 @@ export default withEnglishFallback({
execute: "執行",
clearValues: "清空參數值",
useRawForAll: "全部使用原始 SQL",
+ ignore: "忽略",
kind: {
string: "字串",
number: "數字",