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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(structure): support fuzzy column search in table editor (#13768)
MingZhe1008e4246ab65e60
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vueindex 621ded03f0..73a1ee17ae 100644--- a/apps/desktop/src/components/structure/TableStructureEditor.vue+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue@@ -8,6 +8,7 @@ import { starRocksAlterOptionsFromDdl, starRocksColumnDefinitionLocked, type Staimport { getColumnDefaultValuePresets } from "@/lib/table/columnDefaultPresets";import { applyDdlStoragePreference } from "@/lib/sql/ddlStorage";import { compactDdlSql } from "@/lib/sql/ddlCompact";+import { matchesIdentifierSearch } from "@/lib/sql/identifierSearch";import DdlStorageToggle from "@/components/objects/DdlStorageToggle.vue";import { exactOracleTriggerMetadata, oracleTriggerReadOptions } from "@/lib/database/oracleTriggerIdentity";import { executeOracleTriggerStructurePlan, readOracleTriggerSource, verifyOracleTriggerDeletion, type OracleTriggerExecutionResult, type OracleTriggerSnapshot, type OracleTriggerTarget } from "@/lib/database/oracleTriggerPlan";@@ -2244,17 +2245,7 @@ const indexColLabels = computed(() => [const filteredColumnRowIds = computed(() => {const query = columnSearchText.value.trim().toLowerCase();if (!query) return new Set<string>();- return new Set(- columns.value- .filter((column) =>- [column.name, column.comment].some((value) =>- String(value ?? "")- .toLowerCase()- .includes(query),- ),- )- .map((column) => column.id),- );+ return new Set(columns.value.filter((column) => columnMatchesSearch(column)).map((column) => column.id));});const columnSearchMatchCount = computed(() => (columnSearchText.value.trim() ? filteredColumnRowIds.value.size : 0));const filteredIndexRowIds = computed(() => {@@ -5477,21 +5468,12 @@ function columnRowClass(column: EditableStructureColumn, index: number) {function columnMatchesSearch(column: EditableStructureColumn): boolean {const query = columnSearchText.value.trim().toLowerCase();if (!query) return false;- return [column.name, column.comment].some((value) =>- String(value ?? "")- .toLowerCase()- .includes(query),- );+ return [column.name, column.comment].some((value) => columnFieldMatchesSearch(value));}function columnFieldMatchesSearch(value: string | null | undefined): boolean {const query = columnSearchText.value.trim().toLowerCase();- return (- !!query &&- String(value ?? "")- .toLowerCase()- .includes(query)- );+ return !!query && matchesIdentifierSearch(String(value ?? ""), query);}function columnSearchFieldClass(column: EditableStructureColumn, value: string | null | undefined) {diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.columnNameWhitespace.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.columnFields.spec.tssimilarity index 83%rename from apps/desktop/src/components/structure/__tests__/TableStructureEditor.columnNameWhitespace.spec.tsrename to apps/desktop/src/components/structure/__tests__/TableStructureEditor.columnFields.spec.tsindex 742290ee3a..937c41b32a 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.columnNameWhitespace.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.columnFields.spec.ts@@ -328,6 +328,53 @@ afterEach(() => {document.body.innerHTML = "";});+describe("TableStructureEditor column search", () => {+ it("finds a column by its comment without changing its name", async () => {+ const draft = draftWithColumns([{ name: "id", originalName: "id" }]);+ draft.columns[0].comment = "Approval Type";+ const root = await mountEditor(draft);+ const search = root.querySelector<HTMLInputElement>('input[placeholder="structureEditor.searchColumns"]')!;+ search.value = "approvaltype";+ search.dispatchEvent(new Event("input", { bubbles: true }));+ await nextTick();++ expect(root.querySelector('button[title="structureEditor.nextColumnMatch"]')?.textContent?.trim()).toBe("1");+ expect(root.querySelector<HTMLInputElement>("[data-column-name-input]")?.value).toBe("id");+ });++ it.each(["pprovetype", "approveType", " APPROVETYPE ", "at", "approve_type"])("finds and navigates to an underscored column for %s", async (query) => {+ const root = await mountEditor(+ draftWithColumns([+ { name: "id", originalName: "id" },+ { name: "approve_type", originalName: "approve_type" },+ ]),+ );+ const search = root.querySelector<HTMLInputElement>('input[placeholder="structureEditor.searchColumns"]')!;+ search.value = query;+ search.dispatchEvent(new Event("input", { bubbles: true }));+ await nextTick();++ const nextMatch = root.querySelector<HTMLButtonElement>('button[title="structureEditor.nextColumnMatch"]')!;+ expect(nextMatch.textContent?.trim()).toBe("1");+ const matchedInput = Array.from(root.querySelectorAll<HTMLInputElement>("[data-column-name-input]")).find((input) => input.value === "approve_type")!;+ expect(matchedInput.closest("tr")?.classList.contains("structure-column-search-match")).toBe(true);+ search.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));+ await nextTick();+ expect(matchedInput.closest("tr")?.classList.contains("structure-column-search-current")).toBe(true);++ search.value = "missing";+ search.dispatchEvent(new Event("input", { bubbles: true }));+ await nextTick();+ expect(nextMatch.textContent?.trim()).toBe("0");+ expect(matchedInput.closest("tr")?.classList.contains("structure-column-search-match")).toBe(false);++ search.value = "";+ search.dispatchEvent(new Event("input", { bubbles: true }));+ await nextTick();+ expect(root.querySelector('button[title="structureEditor.nextColumnMatch"]')).toBeNull();+ });+});+describe("TableStructureEditor column name whitespace", () => {// MySQL rejects identifiers that end with a space (ERROR 1166 "Incorrect column// name"), so a pasted name carrying a trailing space produced an unexecutablediff --git a/docs/testing/issue-13586-column-search-dark.png b/docs/testing/issue-13586-column-search-dark.pngnew file mode 100644index 0000000000..d5beedce8cBinary files /dev/null and b/docs/testing/issue-13586-column-search-dark.png differdiff --git a/docs/testing/issue-13586-column-search-light.png b/docs/testing/issue-13586-column-search-light.pngnew file mode 100644index 0000000000..3fca229358Binary files /dev/null and b/docs/testing/issue-13586-column-search-light.png differ