This repository was archived by the owner on May 18, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
This repository was archived by the owner on May 18, 2024. It is now read-only.
InsertCollection.getDependencies()
is dangerous #82
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
When tree structured table comes, InsertCollection.getDependencies()
would be fallen into infinite recursive function call.
safe-typeorm/src/transactions/InsertCollection.ts
Lines 152 to 176 in 0f5f2e6
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 workingSomething isn't workingenhancementNew feature or requestNew feature or request