mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-10 16:53:35 +08:00
🐛 fix(table-overview): 修复未知存储大小误显示为零
将 Oracle、达梦和默认方言不支持的存储统计改为 NULL 占位。 补充 Oracle 与默认方言回归测试,保留 SQLite 真实零值的 0 B 展示。
This commit is contained in:
@@ -242,6 +242,61 @@ describe('TableOverview metadata compatibility', () => {
|
||||
expect(renderedText).toContain('100%');
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ type: 'oracle', dbName: 'APP' },
|
||||
{ type: 'trino', dbName: 'catalog' },
|
||||
])('keeps unsupported $type storage metrics unknown', async ({ type, dbName }) => {
|
||||
storeState.connections = [
|
||||
{
|
||||
id: 'conn-1',
|
||||
config: {
|
||||
type,
|
||||
host: '127.0.0.1',
|
||||
port: 0,
|
||||
user: 'tester',
|
||||
password: 'secret',
|
||||
database: dbName,
|
||||
useSSH: false,
|
||||
ssh: { host: '', port: 22, user: '', password: '', keyPath: '' },
|
||||
},
|
||||
},
|
||||
];
|
||||
backendApp.DBQuery.mockResolvedValue({
|
||||
success: true,
|
||||
data: [
|
||||
{
|
||||
table_name: 'orders',
|
||||
table_rows: '8',
|
||||
data_length: null,
|
||||
index_length: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
let renderer: ReactTestRenderer;
|
||||
await act(async () => {
|
||||
renderer = create(<TableOverview tab={{
|
||||
id: 'tab-1',
|
||||
title: `表概览 - ${dbName}`,
|
||||
type: 'table-overview',
|
||||
connectionId: 'conn-1',
|
||||
dbName,
|
||||
} as any} />);
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(backendApp.DBGetTables).not.toHaveBeenCalled();
|
||||
expect(backendApp.DBQuery).toHaveBeenCalledOnce();
|
||||
const metadataSQL = String(backendApp.DBQuery.mock.calls[0]?.[2] || '');
|
||||
expect(metadataSQL).toMatch(/NULL AS data_length/i);
|
||||
expect(metadataSQL).toMatch(/NULL AS index_length/i);
|
||||
|
||||
const renderedText = collectText(renderer!.toJSON());
|
||||
expect(renderedText).toContain('orders');
|
||||
expect(renderedText).toContain('—');
|
||||
expect(renderedText).not.toContain('0 B');
|
||||
});
|
||||
|
||||
it('uses the table default open behavior for v2 card double-clicks', async () => {
|
||||
storeState.appearance = { uiVersion: 'v2', tableDoubleClickAction: 'open-design' };
|
||||
let renderer: ReactTestRenderer;
|
||||
|
||||
@@ -210,10 +210,10 @@ ORDER BY s.name, t.name`;
|
||||
case 'dm':
|
||||
case 'oracle': {
|
||||
const owner = (schemaName || dbName).toUpperCase();
|
||||
return `SELECT table_name, comments AS table_comment, num_rows AS table_rows, 0 AS data_length, 0 AS index_length FROM all_tab_comments JOIN all_tables USING (table_name, owner) WHERE owner = '${escapeLiteral(owner)}' ORDER BY table_name`;
|
||||
return `SELECT table_name, comments AS table_comment, num_rows AS table_rows, NULL AS data_length, NULL AS index_length FROM all_tab_comments JOIN all_tables USING (table_name, owner) WHERE owner = '${escapeLiteral(owner)}' ORDER BY table_name`;
|
||||
}
|
||||
default:
|
||||
return `SELECT table_name, '' AS table_comment, 0 AS table_rows, 0 AS data_length, 0 AS index_length FROM information_schema.tables WHERE table_schema = '${escapeLiteral(dbName)}' AND table_type = 'BASE TABLE' ORDER BY table_name`;
|
||||
return `SELECT table_name, '' AS table_comment, 0 AS table_rows, NULL AS data_length, NULL AS index_length FROM information_schema.tables WHERE table_schema = '${escapeLiteral(dbName)}' AND table_type = 'BASE TABLE' ORDER BY table_name`;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user