fix(structure): preserve object schema for editor

This commit is contained in:
t8y2 2026-05-19 12:35:22 +08:00
parent 653feb7c65
commit 7625c1aae9
2 changed files with 27 additions and 10 deletions

View File

@ -124,16 +124,19 @@ export function buildGroupedObjectTreeNodes({
schema,
objectCount: items.length,
isExpanded: false,
children: items.map((obj) => ({
id: `${nodeId}:${def.key}:${obj.name}`,
label: obj.name,
type: def.childType,
connectionId,
database,
schema,
isExpanded: false,
children: isExpandable ? [] : undefined,
})),
children: items.map((obj) => {
const childSchema = obj.schema ? normalizeDatabaseObjectName(obj.schema) : schema;
return {
id: `${nodeId}:${def.key}:${childSchema ? `${childSchema}:` : ""}${obj.name}`,
label: obj.name,
type: def.childType,
connectionId,
database,
schema: childSchema,
isExpanded: false,
children: isExpandable ? [] : undefined,
};
}),
});
}
return groups;

View File

@ -108,6 +108,20 @@ test("object tree groups count unique objects when metadata returns duplicates",
);
});
test("object tree table nodes keep the schema returned by metadata", () => {
const nodes = buildGroupedObjectTreeNodes({
nodeId: "conn:app",
connectionId: "conn",
database: "app",
schema: "app",
objects: [obj("orders", "TABLE", "sales")],
});
const tableNode = nodes.find((node) => node.type === "group-tables")?.children?.[0];
assert.equal(tableNode?.schema, "sales");
});
test("expands cached object-browser nodes back into regular table nodes", () => {
const nodes = expandCachedObjectBrowserNodes([
{