diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue index 625f2ba36..4919ce365 100644 --- a/apps/desktop/src/components/sidebar/TreeItem.vue +++ b/apps/desktop/src/components/sidebar/TreeItem.vue @@ -320,7 +320,7 @@ async function toggle() { } else if (node.type === "schema" && node.connectionId && node.database && node.schema) { await connectionStore.loadTables(node.connectionId, node.database, node.schema); } else if ((node.type === "table" || node.type === "view") && node.connectionId && node.database) { - await connectionStore.loadTableGroups(node.connectionId, node.database, node.label, node.schema); + await connectionStore.loadTableGroups(node.connectionId, node.database, node.label, node.schema, node.id); } else if (node.type === "group-columns" && node.connectionId && node.database && node.tableName) { await connectionStore.loadColumns(node.connectionId, node.database, node.tableName, node.schema); } else if (node.type === "group-indexes" && node.connectionId && node.database && node.tableName) { diff --git a/packages/app-tests/tableTree.test.ts b/packages/app-tests/tableTree.test.ts index 81d475183..1c3670631 100644 --- a/packages/app-tests/tableTree.test.ts +++ b/packages/app-tests/tableTree.test.ts @@ -1,8 +1,15 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { buildTableTreeNodes, expandCachedObjectBrowserNodes, objectGroupRefreshParentId } from "../../apps/desktop/src/lib/tableTree.ts"; +import { readFileSync } from "node:fs"; +import { + buildTableTreeNodes, + expandCachedObjectBrowserNodes, + objectGroupRefreshParentId, +} from "../../apps/desktop/src/lib/tableTree.ts"; import type { TableInfo } from "../../apps/desktop/src/types/database.ts"; +const treeItemSource = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8"); + function table(name: string, tableType: "TABLE" | "VIEW" = "TABLE"): TableInfo { return { name, table_type: tableType }; } @@ -114,3 +121,10 @@ test("resolves grouped object refreshes to the parent schema node", () => { "conn:db:public", ); }); + +test("table expander loads groups by the actual tree node id", () => { + assert.match( + treeItemSource, + /loadTableGroups\(node\.connectionId,\s*node\.database,\s*node\.label,\s*node\.schema,\s*node\.id\)/, + ); +});