From d5b496e597bdd4ec69ff8c0d62b6d8d3c9c6cb2c Mon Sep 17 00:00:00 2001 From: JYC333 <22962980+JYC333@users.noreply.github.com> Date: Mon, 9 Mar 2026 01:10:26 +0000 Subject: [PATCH] fix: relation definition is not included when create relation in relation map --- apps/server/src/services/attributes.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/apps/server/src/services/attributes.ts b/apps/server/src/services/attributes.ts index 2e1a207447..f2738a618e 100644 --- a/apps/server/src/services/attributes.ts +++ b/apps/server/src/services/attributes.ts @@ -71,6 +71,27 @@ function getAttributeNames(type: string, nameLike: string) { [type, `%${nameLike}%`] ); + // Also include attribute definitions (e.g. 'relation:*' or 'label:*') which are saved as type='label' + if (type === "relation" || type === "label") { + const prefix = `${type}:`; + const defNames = sql.getColumn( + /*sql*/`SELECT DISTINCT name + FROM attributes + WHERE isDeleted = 0 + AND type = 'label' + AND name LIKE ?`, + [`${prefix}%${nameLike}%`] + ); + for (const dn of defNames) { + if (dn.startsWith(prefix)) { + const stripped = dn.substring(prefix.length); + if (!names.includes(stripped)) { + names.push(stripped); + } + } + } + } + for (const attr of BUILTIN_ATTRIBUTES) { if (attr.type === type && attr.name.toLowerCase().includes(nameLike) && !names.includes(attr.name)) { names.push(attr.name);