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): honor keyword case when pasting IN values

zipgfdba3301b4b9
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index 2e56d90f91..4823e18603 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -1128,7 +1128,7 @@ async function pasteClipboardAsSqlInCondition(): Promise<boolean> {
}
}
- const result = buildSqlInConditionFromPasteSource(source);
+ const result = buildSqlInConditionFromPasteSource(source, settingsStore.editorSettings.sqlFormatter.keywordCase);
if (!result.ok) {
const key = result.reason === "too-large" ? "editor.exPasteTooLarge" : result.reason === "too-many-values" ? "editor.exPasteTooManyValues" : result.reason === "not-list" ? "editor.exPasteNotList" : "editor.exPasteNoValues";
toast(t(key, { limit: result.limit ?? 0 }), 5000);
diff --git a/apps/desktop/src/lib/__tests__/sql/sqlInListPaste.spec.ts b/apps/desktop/src/lib/__tests__/sql/sqlInListPaste.spec.ts
index cfb3d8637d..3990f0389c 100644
--- a/apps/desktop/src/lib/__tests__/sql/sqlInListPaste.spec.ts
+++ b/apps/desktop/src/lib/__tests__/sql/sqlInListPaste.spec.ts
@@ -10,6 +10,19 @@ describe("sqlInListPaste", () => {
});
});
+ it("uses the configured SQL keyword case", () => {
+ expect(buildSqlInConditionFromPasteSource("A\nB", "lower")).toEqual({
+ ok: true,
+ sql: "in ('A', 'B')",
+ valueCount: 2,
+ });
+ expect(buildSqlInConditionFromPasteSource("A\nB", "upper")).toEqual({
+ ok: true,
+ sql: "IN ('A', 'B')",
+ valueCount: 2,
+ });
+ });
+
it("splits comma, tab, and newline separated clipboard content", () => {
expect(buildSqlInConditionFromPasteSource("A\tB\nC,D")).toEqual({
ok: true,
diff --git a/apps/desktop/src/lib/sql/sqlInListPaste.ts b/apps/desktop/src/lib/sql/sqlInListPaste.ts
index c3ae86163c..23d936f663 100644
--- a/apps/desktop/src/lib/sql/sqlInListPaste.ts
+++ b/apps/desktop/src/lib/sql/sqlInListPaste.ts
@@ -27,7 +27,7 @@ interface ParsedPasteValues {
const SIMPLE_SLASH_LIST_VALUE_RE = /^[A-Za-z0-9_.:-]+$/;
-export function buildSqlInConditionFromPasteSource(source: string): SqlInListPasteResult {
+export function buildSqlInConditionFromPasteSource(source: string, keywordCase: "preserve" | "upper" | "lower" = "upper"): SqlInListPasteResult {
if (source.length > SQL_IN_LIST_PASTE_MAX_SOURCE_LENGTH) {
return { ok: false, reason: "too-large", limit: SQL_IN_LIST_PASTE_MAX_SOURCE_LENGTH };
}
@@ -41,9 +41,10 @@ export function buildSqlInConditionFromPasteSource(source: string): SqlInListPas
}
const literals = values.map(formatSqlLiteral);
+ const inKeyword = keywordCase === "lower" ? "in" : "IN";
return {
ok: true,
- sql: `IN (${literals.join(", ")})`,
+ sql: `${inKeyword} (${literals.join(", ")})`,
valueCount: values.length,
};
}