Skip to content

Commit 5267dea

Browse files
authored
eng-1262: allow for same id, different triples (#679)
* eng-1262: allow for same id, different triples
1 parent d747191 commit 5267dea

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

apps/roam/src/components/CreateRelationDialog.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,18 @@ const CreateRelationDialog = ({
133133
});
134134
return null;
135135
}
136-
if (candidateRelations.length !== 1) {
137-
// This seems to happen... I need more data.
138-
internalError({
139-
type: "Create Relation dialog",
140-
error: `Too many relations between ${selectedTargetType.type} and ${selectedSourceType.type}: ${candidateRelations.map((r) => r.id).join(",")}`,
141-
});
142-
return null;
136+
if (candidateRelations.length > 1) {
137+
// Control for one very innocuous case: Many times the same relation, with different triples.
138+
const setOfRels = new Set(
139+
candidateRelations.map((r) => (r.forward ? r.id : `-${r.id}`)),
140+
);
141+
if (setOfRels.size > 1) {
142+
internalError({
143+
type: "Create Relation dialog",
144+
error: `Too many relations between ${selectedTargetType.type} and ${selectedSourceType.type}: ${[...setOfRels].join(",")}`,
145+
});
146+
// let it still fall through to the first
147+
}
143148
}
144149
return candidateRelations[0];
145150
};

0 commit comments

Comments
 (0)