diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vue index 322d08514..f0bec0d5c 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(() => 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( >
{{ t("objects.name") }}
{{ t("objects.type") }}
-
{{ t("objects.schemaColumn") }}
{{ t("objects.comment") }}
{{ item.name }}
{{ typeLabel(item.type) }}
-
{{ item.schema || props.database }}
{{ item.comment || "" }}
diff --git a/apps/desktop/src/lib/objectBrowserRows.ts b/apps/desktop/src/lib/objectBrowserRows.ts index 6e97b2316..96ef16a8f 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 91f2a77f7..a6440d1c9 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"], + ); +});