mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-12 07:52:44 +08:00
🐛 fix(sidebar): 修复 Oracle 表元数据显示缺失
- Oracle/Dameng 表元数据查询移除 ALL_SEGMENTS 依赖 - 使用 ALL_TABLES.BLOCKS 轻量估算表大小,避免权限或大库聚合失败 - 保留表注释、行数、创建时间和最后 DDL 时间展示 - 补充 Oracle-like 元数据 SQL 回归断言
This commit is contained in:
@@ -3131,7 +3131,9 @@ describe('Sidebar locate toolbar', () => {
|
||||
expect(sqlServerSql).toContain('ep.value AS table_comment');
|
||||
expect(sqlServerSql).toContain('t.create_date AS create_time');
|
||||
expect(oracleSql).toContain('comments AS table_comment');
|
||||
expect(oracleSql).toContain('COALESCE(t.blocks, 0) * 8192 AS table_size');
|
||||
expect(oracleSql).toContain('o.last_ddl_time AS update_time');
|
||||
expect(oracleSql).not.toContain('all_segments');
|
||||
|
||||
const loaderSource = readSourceFile('./sidebar/useSidebarTreeLoaders.tsx');
|
||||
expect(loaderSource).toContain('tableMetadataMap');
|
||||
|
||||
@@ -12,9 +12,14 @@ describe('Sidebar Dameng table count regression', () => {
|
||||
|
||||
expect(damengSql).toContain('owner AS schema_name');
|
||||
expect(damengSql).toContain('comments AS table_comment');
|
||||
expect(damengSql).toContain('COALESCE(t.blocks, 0) * 8192 AS table_size');
|
||||
expect(damengSql).not.toContain('all_segments');
|
||||
expect(oracleSql).toContain('owner AS schema_name');
|
||||
expect(oracleSql).toContain('COALESCE(t.blocks, 0) * 8192 AS table_size');
|
||||
expect(oracleSql).not.toContain('all_segments');
|
||||
|
||||
expect(loaderSource).toContain('const tableSchemaMap = new Map<string, string>();');
|
||||
expect(loaderSource).toContain('const tableMetadataMap = new Map<string, SidebarTableMetadataSnapshot & { schemaName?: string }>();');
|
||||
expect(loaderSource).toContain('const buildTableMetadataKeys = (rawTableName: string, rawSchemaName = \'\'): string[] => {');
|
||||
expect(loaderSource).toContain("getCaseInsensitiveValue(row, ['schema_name', 'SCHEMA_NAME', 'owner', 'OWNER'])");
|
||||
expect(loaderSource).toContain('const normalizedSchemaRows = schemaRows');
|
||||
expect(loaderSource).toContain('normalizedSchemaRows.length !== 1');
|
||||
|
||||
@@ -315,13 +315,11 @@ const buildSidebarTableStatusSQL = (
|
||||
const owner = escapeSQLLiteral(dbName).toUpperCase();
|
||||
return [
|
||||
"SELECT c.owner AS schema_name, c.table_name, c.comments AS table_comment, t.num_rows AS table_rows,",
|
||||
"COALESCE(SUM(s.bytes), 0) AS table_size, o.created AS create_time, o.last_ddl_time AS update_time",
|
||||
"COALESCE(t.blocks, 0) * 8192 AS table_size, o.created AS create_time, o.last_ddl_time AS update_time",
|
||||
"FROM all_tab_comments c",
|
||||
"JOIN all_tables t ON t.owner = c.owner AND t.table_name = c.table_name",
|
||||
"LEFT JOIN all_objects o ON o.owner = t.owner AND o.object_name = t.table_name AND o.object_type = 'TABLE'",
|
||||
"LEFT JOIN all_segments s ON s.owner = t.owner AND s.segment_name = t.table_name AND s.segment_type = 'TABLE'",
|
||||
`WHERE c.owner = '${owner}'`,
|
||||
"GROUP BY c.owner, c.table_name, c.comments, t.num_rows, o.created, o.last_ddl_time",
|
||||
"ORDER BY c.table_name",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user