|
1 | 1 | import * as vscode from 'vscode'; |
2 | 2 | import * as sql from 'mssql'; |
3 | 3 | import { ConnectionProvider, ConnectionConfig, ServerGroup } from './connectionProvider'; |
4 | | -import { createServerGroupIcon, createTableIcon, createColumnIcon, createStoredProcedureIcon, createViewIcon, createLoadingSpinnerIcon, createDatabaseIcon, createFunctionIcon, createTriggerIcon, createTypeIcon, createSequenceIcon, createSynonymIcon, createAssemblyIcon } from './serverGroupIcon'; |
| 4 | +import { createServerGroupIcon, createTableIcon, createColumnIcon, createStoredProcedureIcon, createViewIcon, createLoadingSpinnerIcon, createDatabaseIcon, createFunctionIcon, createTriggerIcon, createTypeIcon, createSequenceIcon, createSynonymIcon, createAssemblyIcon, createTemporalTableIcon } from './serverGroupIcon'; |
5 | 5 | import { SchemaCache } from './utils/schemaCache'; |
6 | 6 |
|
7 | 7 | export class UnifiedTreeProvider implements vscode.TreeDataProvider<TreeNode>, vscode.FileDecorationProvider, vscode.TreeDragAndDropController<TreeNode> { |
@@ -751,10 +751,13 @@ export class UnifiedTreeProvider implements vscode.TreeDataProvider<TreeNode>, v |
751 | 751 | this.outputChannel.appendLine(`[UnifiedTreeProvider] Found ${cachedTables.length} tables to display in database ${element.database || 'current'}`); |
752 | 752 | } |
753 | 753 |
|
754 | | - return tablesToDisplay.map((table) => { |
| 754 | + return tablesToDisplay |
| 755 | + .filter(table => table.temporalType !== 1) |
| 756 | + .map((table) => { |
| 757 | + const itemType = table.temporalType === 2 ? 'temporal-table' : 'table'; |
755 | 758 | const tableNode = new SchemaItemNode( |
756 | 759 | `${table.schema}.${table.name}`, |
757 | | - 'table', |
| 760 | + itemType, |
758 | 761 | table.schema, |
759 | 762 | vscode.TreeItemCollapsibleState.Collapsed |
760 | 763 | ); |
@@ -784,8 +787,9 @@ export class UnifiedTreeProvider implements vscode.TreeDataProvider<TreeNode>, v |
784 | 787 | formattedSize = '< 1 MB'; |
785 | 788 | } |
786 | 789 |
|
787 | | - // Set description: "1.6k Rows 34 MB" |
788 | | - tableNode.description = `${formattedRows} Rows ${formattedSize}`; |
| 790 | + // Set description: "1.6k Rows 34 MB" (+ system-versioned label for temporal tables) |
| 791 | + const temporalSuffix = table.temporalType === 2 ? ' (system-versioned)' : ''; |
| 792 | + tableNode.description = `${formattedRows} Rows ${formattedSize}${temporalSuffix}`; |
789 | 793 | } |
790 | 794 |
|
791 | 795 | return tableNode; |
@@ -1132,7 +1136,7 @@ export class UnifiedTreeProvider implements vscode.TreeDataProvider<TreeNode>, v |
1132 | 1136 | } |
1133 | 1137 |
|
1134 | 1138 | return items; |
1135 | | - } else if (element.itemType === 'table') { |
| 1139 | + } else if (element.itemType === 'table' || element.itemType === 'temporal-table') { |
1136 | 1140 | // Show table details (columns, keys, etc.) |
1137 | 1141 | // Extract table name from label format schema.tableName |
1138 | 1142 | const fullLabel = element.label as string; |
@@ -1604,6 +1608,27 @@ export class UnifiedTreeProvider implements vscode.TreeDataProvider<TreeNode>, v |
1604 | 1608 | statisticsNode.database = database; |
1605 | 1609 | items.push(statisticsNode); |
1606 | 1610 |
|
| 1611 | + // History table node for system-versioned (temporal) tables |
| 1612 | + const allTables = await this.schemaCache.getTables(cacheConnection, connection); |
| 1613 | + const currentTable = allTables.find(t => |
| 1614 | + t.name.toLowerCase() === tableName.toLowerCase() && |
| 1615 | + t.schema.toLowerCase() === schema.toLowerCase() |
| 1616 | + ); |
| 1617 | + if (currentTable?.temporalType === 2 && currentTable.historyTableName && currentTable.historyTableSchema) { |
| 1618 | + const historyNode = new SchemaItemNode( |
| 1619 | + `${currentTable.historyTableSchema}.${currentTable.historyTableName}`, |
| 1620 | + 'table', |
| 1621 | + currentTable.historyTableSchema, |
| 1622 | + vscode.TreeItemCollapsibleState.Collapsed |
| 1623 | + ); |
| 1624 | + (historyNode as any).tableName = currentTable.historyTableName; |
| 1625 | + historyNode.connectionId = connectionId; |
| 1626 | + historyNode.database = database; |
| 1627 | + historyNode.iconPath = new vscode.ThemeIcon('history'); |
| 1628 | + historyNode.description = '(History)'; |
| 1629 | + items.push(historyNode); |
| 1630 | + } |
| 1631 | + |
1607 | 1632 | this.outputChannel.appendLine(`[UnifiedTreeProvider] Returning ${items.length} items from cache for table ${tableName}`); |
1608 | 1633 | return items; |
1609 | 1634 | } |
@@ -2695,6 +2720,10 @@ export class SchemaItemNode extends TreeNode { |
2695 | 2720 | this.iconPath = createTableIcon(); |
2696 | 2721 | this.contextValue = 'table'; |
2697 | 2722 | break; |
| 2723 | + case 'temporal-table': |
| 2724 | + this.iconPath = createTemporalTableIcon(); |
| 2725 | + this.contextValue = 'table'; |
| 2726 | + break; |
2698 | 2727 | case 'view': |
2699 | 2728 | this.iconPath = createViewIcon(); |
2700 | 2729 | this.contextValue = 'view'; |
|
0 commit comments