fix(sidebar): dedupe MySQL table objects

This commit is contained in:
t8y2
2026-06-03 14:27:26 +08:00
parent 8bce370a0b
commit 381bdfdfd7
2 changed files with 32 additions and 2 deletions
+9 -2
View File
@@ -231,13 +231,20 @@ export function mergeTableInfosIntoObjects(
if (objectType !== "TABLE" && objectType !== "VIEW") continue;
const name = normalizeDatabaseObjectName(table.name);
if (!name) continue;
const key = `${objectType}\0${(schema || "").toLowerCase()}\0${name.toLowerCase()}`;
const matchingObject = objects.find((obj) => {
const objName = normalizeDatabaseObjectName(obj.name);
if (objName.toLowerCase() !== name.toLowerCase()) return false;
return normalizeObjectType(obj.object_type) === objectType;
});
const tableSchema =
schema ?? (matchingObject?.schema ? normalizeDatabaseObjectName(matchingObject.schema) : undefined);
const key = `${objectType}\0${(tableSchema || "").toLowerCase()}\0${name.toLowerCase()}`;
if (seen.has(key)) continue;
seen.add(key);
merged.push({
name,
object_type: objectType,
schema,
schema: tableSchema,
comment: table.comment,
created_at: undefined,
updated_at: undefined,