fix(GOV-012): 兼容 MySQL 5.7 视图目录并封存 v0.0.9 基线

This commit is contained in:
2026-08-18 02:57:40 +08:00
parent 874796ab65
commit afd186c8a4
4 changed files with 146 additions and 15 deletions
@@ -153,6 +153,49 @@ test('目录查询使用固定参数和超时并返回稳定对象', async () =>
}
});
test('MySQL 5.7 缺少 VIEW_TABLE_USAGE 时从 VIEWS 定义解析依赖', async () => {
const fallback = createCatalogConnection();
const connection = {
calls: fallback.calls,
async query(options) {
if (options.sql.includes('information_schema.VIEW_TABLE_USAGE')) {
throw Object.assign(new Error('unknown metadata table'), { code: 'ER_UNKNOWN_TABLE' });
}
if (options.sql.includes('information_schema.VIEWS')) {
return [
[
{
VIEW_NAME: 'market_dashboard',
VIEW_DEFINITION:
'SELECT * FROM `a_share_analysis_dev`.`market_summary`',
},
{
VIEW_NAME: 'market_summary',
VIEW_DEFINITION: 'SELECT * FROM `market_snapshot`',
},
],
[],
];
}
return fallback.query(options);
},
};
const catalog = await readSchemaCatalog(connection, 'a_share_analysis_dev', DEFAULT_EXPORT_LIMITS);
assert.deepEqual(catalog.viewDependencies, [
{
view: 'market_dashboard',
referencedSchema: 'a_share_analysis_dev',
referencedObject: 'market_summary',
},
{
view: 'market_summary',
referencedSchema: 'a_share_analysis_dev',
referencedObject: 'market_snapshot',
},
]);
});
test('视图按依赖拓扑排序且同层按名称稳定排序', () => {
const catalog = {
tables: ['market_snapshot'],