Skip to content

Commit ae05a7a

Browse files
committed
fix: relation definition is not included when create relation in relation map
1 parent 1e503b0 commit ae05a7a

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

apps/server/src/services/attributes.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@ function getAttributeNames(type: string, nameLike: string) {
7171
[type, `%${nameLike}%`]
7272
);
7373

74+
// Also include attribute definitions (e.g. 'relation:*' or 'label:*') which are saved as type='label'
75+
if (type === "relation" || type === "label") {
76+
const prefix = `${type}:`;
77+
const defNames = sql.getColumn<string>(
78+
/*sql*/`SELECT DISTINCT name
79+
FROM attributes
80+
WHERE isDeleted = 0
81+
AND type = 'label'
82+
AND name LIKE ?`,
83+
[`${prefix}%${nameLike}%`]
84+
);
85+
for (const dn of defNames) {
86+
if (dn.startsWith(prefix)) {
87+
const stripped = dn.substring(prefix.length);
88+
if (!names.includes(stripped)) {
89+
names.push(stripped);
90+
}
91+
}
92+
}
93+
}
94+
7495
for (const attr of BUILTIN_ATTRIBUTES) {
7596
if (attr.type === type && attr.name.toLowerCase().includes(nameLike) && !names.includes(attr.name)) {
7697
names.push(attr.name);

0 commit comments

Comments
 (0)