Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ const en = {
"Duplicate type fields by name '{{fieldName}}' in type '{{typeName}}'",
duplicate_reference: "Duplicate reference by the name '{{refName}}'",
circular_dependency: "Circular dependency involving table '{{refName}}'",
circular_type_dependency: "Circular type dependency involving type '{{typeName}}'",
timeline: "Timeline",
priority: "Priority",
none: "None",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const es = {
"Campos de tipo duplicados por nombre '{{fieldName}}' en el tipo '{{typeName}}'",
duplicate_reference: "Referencia duplicada con el nombre '{{refName}}'",
circular_dependency: "Dependencia circular involucrando la tabla '{{refName}}'",
circular_type_dependency: "Dependencia circular de tipos involucrando el tipo '{{typeName}}'",
timeline: "Linea del tiempo",
priority: "Prioridad",
none: "Ninguno",
Expand Down
34 changes: 34 additions & 0 deletions src/utils/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export function getIssues(diagram) {
}
});

// Check for circular table relationships
const visitedTables = new Set();

function checkCircularRelationships(tableId, visited = []) {
Expand Down Expand Up @@ -230,5 +231,38 @@ export function getIssues(diagram) {
}
});

// Check for circular type dependencies
function checkCircularTypes(typeName, visited = []) {
if (visited.includes(typeName)) {
issues.push(
i18n.t("circular_type_dependency", {
typeName: typeName,
}),
);
return;
}

const currentType = diagram.types.find((t) => t.name === typeName);
if (!currentType) return;

visited.push(typeName);

currentType.fields.forEach((field) => {
// Check if this field references another custom type
const referencedType = diagram.types.find((t) => t.name === field.type);
if (referencedType && field.type !== typeName) {
checkCircularTypes(field.type, [...visited]);
}
});
}

const visitedTypes = new Set();
diagram.types.forEach((type) => {
if (!visitedTypes.has(type.name)) {
visitedTypes.add(type.name);
checkCircularTypes(type.name);
}
});

return issues;
}