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(sidebar): prevent table virtual groups from mounting on table and column children (#12960) (#12974)
lxk95527503a5d5799
diff --git a/apps/desktop/src/lib/table/__tests__/tableVGroup.spec.ts b/apps/desktop/src/lib/table/__tests__/tableVGroup.spec.tsindex 7972a945cb..351a12f77e 100644--- a/apps/desktop/src/lib/table/__tests__/tableVGroup.spec.ts+++ b/apps/desktop/src/lib/table/__tests__/tableVGroup.spec.ts@@ -326,6 +326,18 @@ describe("resolveTableVGroupScopeFromNode", () => {tablesGroup.children = [row, groupRow];expect(resolveTableVGroupScopeFromNode([databaseNode], groupRow)).toEqual(resolveTableVGroupScopeFromNode([databaseNode], databaseNode));});++ it("refuses scopes for non-groupable metadata and table structural children", () => {+ const columnsGroup: TreeNode = { id: "conn-1:main:t_order:__columns", label: "Columns", type: "group-columns", connectionId: "conn-1", database: "main", tableName: "t_order" };+ const columnNode: TreeNode = { id: "conn-1:main:t_order:col:id", label: "id", type: "column", connectionId: "conn-1", database: "main", tableName: "t_order" };+ const indexesGroup: TreeNode = { id: "conn-1:main:t_order:__indexes", label: "Indexes", type: "group-indexes", connectionId: "conn-1", database: "main", tableName: "t_order" };+ const tableTriggersGroup: TreeNode = { id: "conn-1:main:t_order:__triggers", label: "Triggers", type: "group-triggers", connectionId: "conn-1", database: "main", tableName: "t_order" };++ expect(resolveTableVGroupScopeFromNode([databaseNode], columnsGroup)).toEqual({});+ expect(resolveTableVGroupScopeFromNode([databaseNode], columnNode)).toEqual({});+ expect(resolveTableVGroupScopeFromNode([databaseNode], indexesGroup)).toEqual({});+ expect(resolveTableVGroupScopeFromNode([databaseNode], tableTriggersGroup)).toEqual({});+ });});describe("table tree helpers", () => {@@ -445,6 +457,12 @@ describe("container-kind scoped groups (views/procedures/triggers)", () => {expect(tableVGroupKindOfContainerNode({ type: "group-types" })).toBe("types");expect(tableVGroupKindOfContainerNode({ type: "group-tablespaces" })).toBeNull();expect(tableVGroupKindOfContainerNode({ type: "group-dolt-system-tables" })).toBeNull();+ expect(tableVGroupKindOfContainerNode({ type: "table" })).toBeNull();+ expect(tableVGroupKindOfContainerNode({ type: "group-columns" })).toBeNull();+ expect(tableVGroupKindOfContainerNode({ type: "group-indexes" })).toBeNull();+ expect(tableVGroupKindOfContainerNode({ type: "group-fkeys" })).toBeNull();+ expect(tableVGroupKindOfContainerNode({ type: "group-constraints" })).toBeNull();+ expect(tableVGroupKindOfContainerNode({ type: "column" })).toBeNull();});it("projects view rows under the views scope and passes non-member rows through", () => {diff --git a/apps/desktop/src/lib/table/tableVGroup.ts b/apps/desktop/src/lib/table/tableVGroup.tsindex 40ccc024c0..5a798f5969 100644--- a/apps/desktop/src/lib/table/tableVGroup.ts+++ b/apps/desktop/src/lib/table/tableVGroup.ts@@ -740,7 +740,7 @@ export function resolveTableVGroupScopeFromNode(nodes: TreeNode[], node: TreeNodconst row = node as Partial<TreeNode> & TableVGroupScope;const containerKind = isTableVGroupContainerNode(row as TreeNode) ? tableVGroupKindOfContainerNode(row as TreeNode) : null;if (containerKind) return { ...tableVGroupScopeFieldsOf(tableVGroupScopeHostOf(nodes, row as TreeNode)), objectType: containerKind };- if (row.type === "table-vgroup" || row.type?.startsWith("group-")) {+ if (row.type === "table-vgroup") {const host = tableVGroupScopeHostOf(nodes, row as TreeNode);const holder = findTableVGroupHolderContainer(nodes, row as TreeNode);return { ...tableVGroupScopeFieldsOf(host), objectType: (holder && tableVGroupKindOfContainerNode(holder)) || "tables" };@@ -756,8 +756,11 @@ export function resolveTableVGroupScopeFromNode(nodes: TreeNode[], node: TreeNodconst host = tableVGroupScopeHostOf(nodes, holder);return { ...tableVGroupScopeFieldsOf(host), objectType: tableVGroupKindOfContainerNode(holder) ?? "tables" };}- const container = findTableVGroupContainerNode(nodes, row as TreeNode);- return tableVGroupScopeFieldsOf(container ? tableVGroupScopeHostOf(nodes, container) : (row as TreeNode));+ if (!row.type) {+ const container = findTableVGroupContainerNode(nodes, row as TableVGroupScope);+ return tableVGroupScopeFieldsOf(container ? tableVGroupScopeHostOf(nodes, container) : (row as TreeNode));+ }+ return {};}/**diff --git a/apps/desktop/src/stores/__tests__/connectionStore.tableVGroups.spec.ts b/apps/desktop/src/stores/__tests__/connectionStore.tableVGroups.spec.tsindex 95f38a7ce0..c4d40c5ec4 100644--- a/apps/desktop/src/stores/__tests__/connectionStore.tableVGroups.spec.ts+++ b/apps/desktop/src/stores/__tests__/connectionStore.tableVGroups.spec.ts@@ -18,6 +18,7 @@ describe("connectionStore table virtual groups during disk reload", () => {checkConnectionHealth: vi.fn().mockResolvedValue(undefined),listInstalledAgents: vi.fn().mockResolvedValue([]),listTables: vi.fn().mockResolvedValue([]),+ getColumns: vi.fn().mockResolvedValue([]),loadPinnedTreeNodeIds: vi.fn().mockResolvedValue([]),loadSidebarLayout: vi.fn().mockResolvedValue(null),loadTableVGroups: vi.fn().mockResolvedValue({}),@@ -138,4 +139,75 @@ describe("connectionStore table virtual groups during disk reload", () => {expect(groupViews.children![0]!.children?.map((node) => node.label)).toEqual(["v_pay"]);expect(labels).toContain("v_other");});++ it("does not mount table virtual groups under table nodes or columns (issue #12960)", async () => {+ const api = await import("@/lib/backend/api");+ const { tableVGroupScopeKey } = await import("@/lib/table/tableVGroup");+ const { useConnectionStore } = await import("@/stores/connectionStore");+ const config: ConnectionConfig = { id: "mysql-12960", name: "MySQL", db_type: "mysql", host: "127.0.0.1", port: 3306, username: "root", password: "", database: "temporal" };+ const scope = { connectionId: config.id, database: "temporal" };+ const layout = {+ version: 1,+ enabled: true,+ groups: [+ { id: "g1", name: "test1", collapsed: false },+ { id: "g2", name: "test2", collapsed: false },+ ],+ order: [+ {+ type: "group" as const,+ id: "g1",+ children: [{ type: "table" as const, name: "activity_info_maps" }],+ },+ {+ type: "group" as const,+ id: "g2",+ children: [],+ },+ ],+ };+ vi.mocked(api.loadConnections).mockResolvedValue([config]);+ vi.mocked(api.loadTableVGroups).mockResolvedValue({ [tableVGroupScopeKey(scope)!]: layout });+ vi.mocked(api.getColumns).mockResolvedValue([+ { name: "shard_id", data_type: "int", is_nullable: false, column_default: null, is_primary_key: true, comment: null },+ { name: "namespace_id", data_type: "binary(16)", is_nullable: false, column_default: null, is_primary_key: false, comment: null },+ ]);+ const store = useConnectionStore();+ await store.initFromDisk();++ const tableNode: TreeNode = {+ id: `${config.id}:temporal:activity_info_maps`,+ label: "activity_info_maps",+ type: "table",+ connectionId: config.id,+ database: "temporal",+ };+ const database: TreeNode = {+ id: `${config.id}:temporal`,+ label: "temporal",+ type: "database",+ connectionId: config.id,+ database: "temporal",+ children: [tableNode],+ isExpanded: true,+ };+ store.connectedIds = new Set([config.id]);+ store.treeNodes[0]!.isExpanded = true;+ store.treeNodes[0]!.children!.push(database);++ // Expand table: loads table groups (columns, indexes, triggers, etc.)+ await store.loadTreeNodeChildren(tableNode);++ // 1. Table node children should only contain structure groups, NO table-vgroup nodes+ expect(tableNode.children?.some((node) => node.type === "table-vgroup")).toBe(false);+ const columnsGroup = tableNode.children?.find((node) => node.type === "group-columns");+ expect(columnsGroup).toBeDefined();++ // Expand columns: loads column rows+ await store.loadTreeNodeChildren(columnsGroup!);++ // 2. Columns group children should only contain column nodes, NO table-vgroup nodes+ expect(columnsGroup!.children?.some((node) => node.type === "table-vgroup")).toBe(false);+ expect(columnsGroup!.children?.map((node) => node.type)).toEqual(["column", "column"]);+ });});diff --git a/apps/desktop/src/stores/connectionStore.ts b/apps/desktop/src/stores/connectionStore.tsindex 01b59c90c1..40654ac279 100644--- a/apps/desktop/src/stores/connectionStore.ts+++ b/apps/desktop/src/stores/connectionStore.ts@@ -82,6 +82,7 @@ import {findTableVGroupContainerNode,hasTableTreeLoadMore,hasTableVGroupEntries,+ isTableVGroupContainerNode,moveTableToVGroup as moveTableToVGroupOp,normalizeTableVGroupLayout as normalizeTableVGroupLayoutOp,pruneTableVGroupMembers as pruneTableVGroupMembersOp,@@ -98,6 +99,7 @@ import {type TableVGroupLayout,type TableVGroupScope,} from "@/lib/table/tableVGroup";+import { isTreeGroupNodeType } from "@/lib/sidebar/treeNodeGroup";import {buildConnectionConfigBundle,parseConnectionConfigObject,@@ -2143,8 +2145,13 @@ export const useConnectionStore = defineStore("connection", () => {persistPinnedTreeNodeIds();}syncPinnedTreeState(children);- const vgroupResolved = resolveTableVGroupScope(parent);- children = applyTableVGroupsToChildren(children, vgroupResolved ? tableVGroupLayouts.value[vgroupResolved.scopeKey] : undefined, vgroupResolved?.scope ?? parent);+ const shouldApplyVGroups = isTableVGroupContainerNode(parent) && !children.some((child) => child.type === "group-tables" || isTreeGroupNodeType(child.type));+ if (shouldApplyVGroups) {+ const vgroupResolved = resolveTableVGroupScope(parent);+ if (vgroupResolved) {+ children = applyTableVGroupsToChildren(children, tableVGroupLayouts.value[vgroupResolved.scopeKey], vgroupResolved.scope);+ }+ }parent.children = markRawLeafTreeNodes(children);loadedTreeNodeChildrenIds.value.add(parent.id);syncConfirmedEmptyTreeNodeId(parent);@@ -10182,6 +10189,7 @@ export const useConnectionStore = defineStore("connection", () => {function reprojectTableVGroupScope(scope: TableVGroupScope, scopeKey: string, tableName?: string, rowType?: string) {const container = findTableVGroupContainerNode(treeNodes.value, scope, tableName, rowType);if (!container?.children) return;+ if (container.children.some((child) => child.type === "group-tables" || isTreeGroupNodeType(child.type))) return;container.children = applyTableVGroupsToChildren(stripTableVGroupsFromChildren(container.children), tableVGroupLayouts.value[scopeKey], scope);}