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(app): exclude schema from object search

t8y2ec0e2498ca92
diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vue
index 322d08514f..f0bec0d5ce 100644
--- a/apps/desktop/src/components/objects/ObjectBrowser.vue
+++ b/apps/desktop/src/components/objects/ObjectBrowser.vue
@@ -47,7 +47,7 @@ import QueryEditor from "@/components/editor/QueryEditor.vue";
import type { SqlFormatDialect } from "@/lib/sqlFormatter";
import { isCancelSearchShortcut } from "@/lib/keyboardShortcuts";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
-import { buildObjectBrowserRows, type ObjectBrowserRow } from "@/lib/objectBrowserRows";
+import { buildObjectBrowserRows, filterObjectBrowserRows, type ObjectBrowserRow } from "@/lib/objectBrowserRows";
type ObjectFilter = "all" | "tables" | "views" | "procedures" | "functions";
@@ -129,16 +129,10 @@ const objectFilters = computed<ObjectFilter[]>(() =>
const showObjectFilter = computed(() => objectFilters.value.length > 2);
const hasComments = computed(() => rows.value.some((row) => row.comment?.trim()));
const gridTemplateColumns = computed(() =>
- hasComments.value ? "minmax(0,1fr) 120px 160px minmax(160px,0.7fr)" : "minmax(0,1fr) 120px 160px",
+ hasComments.value ? "minmax(0,1fr) 120px minmax(160px,0.7fr)" : "minmax(0,1fr) 120px",
);
const searchedRows = computed(() => {
- const q = search.value.trim().toLowerCase();
- if (!q) return rows.value;
- return rows.value.filter((row) =>
- [row.name, row.schema, row.type, row.comment]
- .filter(Boolean)
- .some((value) => String(value).toLowerCase().includes(q)),
- );
+ return filterObjectBrowserRows(rows.value, search.value);
});
const filteredRows = computed(() => {
if (objectFilter.value === "tables") return searchedRows.value.filter((row) => row.type === "TABLE");
@@ -614,7 +608,6 @@ watch(
>
<div class="truncate">{{ t("objects.name") }}</div>
<div class="truncate">{{ t("objects.type") }}</div>
- <div class="truncate">{{ t("objects.schemaColumn") }}</div>
<div v-if="hasComments" class="truncate">{{ t("objects.comment") }}</div>
</div>
<RecycleScroller
@@ -639,7 +632,6 @@ watch(
<span class="truncate text-[13px] font-medium text-foreground">{{ item.name }}</span>
</div>
<div class="truncate text-xs text-muted-foreground">{{ typeLabel(item.type) }}</div>
- <div class="truncate text-xs text-muted-foreground">{{ item.schema || props.database }}</div>
<div v-if="hasComments" class="truncate text-xs text-muted-foreground" :title="item.comment || ''">
{{ item.comment || "" }}
</div>
diff --git a/apps/desktop/src/lib/objectBrowserRows.ts b/apps/desktop/src/lib/objectBrowserRows.ts
index 6e97b23164..96ef16a8f5 100644
--- a/apps/desktop/src/lib/objectBrowserRows.ts
+++ b/apps/desktop/src/lib/objectBrowserRows.ts
@@ -44,3 +44,11 @@ export function buildObjectBrowserRows(options: {
];
});
}
+
+export function filterObjectBrowserRows(rows: ObjectBrowserRow[], query: string): ObjectBrowserRow[] {
+ const q = query.trim().toLowerCase();
+ if (!q) return rows;
+ return rows.filter((row) =>
+ [row.name, row.type, row.comment].filter(Boolean).some((value) => String(value).toLowerCase().includes(q)),
+ );
+}
diff --git a/packages/app-tests/objectBrowserRows.test.ts b/packages/app-tests/objectBrowserRows.test.ts
index 91f2a77f7f..a6440d1c94 100644
--- a/packages/app-tests/objectBrowserRows.test.ts
+++ b/packages/app-tests/objectBrowserRows.test.ts
@@ -1,6 +1,6 @@
import { strict as assert } from "node:assert";
import test from "node:test";
-import { buildObjectBrowserRows } from "../../apps/desktop/src/lib/objectBrowserRows.ts";
+import { buildObjectBrowserRows, filterObjectBrowserRows } from "../../apps/desktop/src/lib/objectBrowserRows.ts";
test("builds unique row ids for overloaded routines with the same visible name", () => {
const rows = buildObjectBrowserRows({
@@ -19,3 +19,21 @@ test("builds unique row ids for overloaded routines with the same visible name",
["dbms_pipe:list_pipes:FUNCTION:0", "dbms_pipe:list_pipes:FUNCTION:1", "dbms_pipe:create_pipe:FUNCTION:0"],
);
});
+
+test("object browser search matches names, types, and comments but not schema names", () => {
+ const rows = buildObjectBrowserRows({
+ objects: [
+ { name: "users", object_type: "TABLE", schema: "exam_hub", comment: "account records" },
+ { name: "orders", object_type: "TABLE", schema: "sales", comment: "exam invoices" },
+ { name: "refresh_exam_stats", object_type: "PROCEDURE", schema: "public" },
+ ],
+ database: "app",
+ fallbackSchema: "public",
+ needsSchema: true,
+ });
+
+ assert.deepEqual(
+ filterObjectBrowserRows(rows, "exam").map((row) => row.name),
+ ["orders", "refresh_exam_stats"],
+ );
+});