Skip to content
This repository was archived by the owner on May 18, 2024. It is now read-only.
This repository was archived by the owner on May 18, 2024. It is now read-only.

InsertCollection.getDependencies() is dangerous #82

@samchon

Description

@samchon

When tree structured table comes, InsertCollection.getDependencies() would be fallen into infinite recursive function call.

function getDependencies<T extends object>(
target: Creator<T>,
connection?: orm.Connection,
): Set<Creator<object>> {
if (!connection) connection = findRepository(target).manager.connection;
return MapUtil.take(dependencies, target, () => {
const output: Set<Creator<object>> = new Set();
for (const meta of connection!.entityMetadatas) {
const child: Creator<object> = meta.target as Creator<object>;
if (child === target) continue;
for (const foreign of meta.foreignKeys)
if (foreign.referencedEntityMetadata.target === target) {
output.add(child);
for (const grand of getDependencies(child, connection))
output.add(grand);
break;
}
}
return output;
});
}
const dependencies: WeakMap<Creator<object>, Set<Creator<object>>> = new Map();

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions