fix(desktop): copy raw column names from tree

This commit is contained in:
t8y2
2026-06-02 00:52:54 +08:00
parent ac7a5b7576
commit d27ad8a14f
2 changed files with 35 additions and 0 deletions
+4
View File
@@ -79,5 +79,9 @@ export function sidebarSelectionCopyAction(event: ShortcutLikeEvent): SidebarSel
export function copyNameForTreeNode(node: TreeNode): string {
if (tableChildGroupNodeTypes.has(node.type) && node.tableName) return node.tableName;
if (databaseChildGroupNodeTypes.has(node.type)) return node.schema || node.database || node.label;
if (node.type === "column") {
if (node.meta && "name" in node.meta) return node.meta.name;
return node.label.replace(/\s+\(.+\)$/, "");
}
return node.label;
}
+31
View File
@@ -136,3 +136,34 @@ test("copying database object group rows uses the parent schema or database name
"db",
);
});
test("copying column rows uses the column name without type suffix", () => {
assert.equal(
copyNameForTreeNode({
id: "conn:db:public:orders:__columns:status",
label: "status (varchar)",
type: "column",
meta: {
name: "status",
data_type: "varchar",
is_nullable: true,
column_default: null,
is_primary_key: false,
extra: null,
comment: null,
numeric_precision: null,
numeric_scale: null,
character_maximum_length: null,
},
}),
"status",
);
assert.equal(
copyNameForTreeNode({
id: "conn:db:public:orders:__columns:status",
label: "status (varchar)",
type: "column",
}),
"status",
);
});