🐛 fix(sidebar): 修复国产兼容库视图定位失败

- 统一 Sidebar 与 SQL 编辑器的元数据方言解析

- 兼容 GDB/GoldenDB/GreatDB 等 MySQL 兼容驱动的视图元数据

- 放宽左侧树视图定位对 objectType 节点的识别
This commit is contained in:
Syngnat
2026-06-10 11:07:50 +08:00
parent 8f86c4419b
commit d6f552d539
8 changed files with 99 additions and 18 deletions

View File

@@ -784,6 +784,17 @@ const getFirstRowValue = (row: Record<string, any>): string => {
return '';
};
const getMySQLShowTablesName = (row: Record<string, any>): string => {
for (const key of Object.keys(row || {})) {
if (!key.toLowerCase().startsWith('tables_in_')) continue;
const value = row[key];
if (value === undefined || value === null) continue;
const normalized = String(value).trim();
if (normalized !== '') return normalized;
}
return '';
};
const normalizeMetadataQuerySpecs = (specs: MetadataQuerySpec[]): MetadataQuerySpec[] => {
const seen = new Set<string>();
const normalized: MetadataQuerySpec[] = [];
@@ -2514,7 +2525,9 @@ const QueryEditor: React.FC<{ tab: TabData; isActive?: boolean }> = ({ tab, isAc
const tableType = getCaseInsensitiveValue(row, ['table_type', 'table type', 'type']);
if (!isSidebarViewTableType(tableType)) return;
const schemaName = String(getCaseInsensitiveValue(row, ['schema_name', 'schemaname', 'owner', 'table_schema', 'db']) || '').trim();
const rawViewName = String(getCaseInsensitiveValue(row, ['view_name', 'viewname', 'table_name', 'name']) || '').trim() || getFirstRowValue(row);
const rawViewName = String(getCaseInsensitiveValue(row, ['view_name', 'viewname', 'table_name', 'name']) || '').trim()
|| getMySQLShowTablesName(row)
|| getFirstRowValue(row);
const normalizedViewName = normalizeSidebarViewName(metadataDialect, dbName, schemaName, rawViewName);
if (!normalizedViewName) return;
const uniqueKey = `${dbName.toLowerCase()}@@${normalizedViewName.toLowerCase()}`;