fix(sidebar): expand grouped table metadata

This commit is contained in:
t8y2 2026-05-18 23:37:35 +08:00
parent e7a8ba2a50
commit 2e3e5f0b2f
2 changed files with 16 additions and 2 deletions

View File

@ -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) {

View File

@ -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\)/,
);
});