Moved the import fetching to occur after the naming strategy is applied, to ensure correct imports.

This commit is contained in:
Vasil Rangelov 2019-11-12 11:04:59 +02:00
parent ecf9f51806
commit 91f9f11b44
2 changed files with 13 additions and 14 deletions

View File

@ -128,10 +128,23 @@ function removeColumnDefaultProperties(
});
return dbModel;
}
function findFileImports(dbModel: Entity[]) {
dbModel.forEach(entity => {
entity.relations.forEach(relation => {
if (!entity.fileImports.some(v => v === relation.relatedTable)) {
entity.fileImports.push(relation.relatedTable);
}
});
});
return dbModel;
}
function addImportsAndGenerationOptions(
dbModel: Entity[],
generationOptions: IGenerationOptions
): Entity[] {
dbModel = findFileImports(dbModel);
dbModel.forEach(entity => {
entity.relations.forEach(relation => {
if (generationOptions.lazy) {

View File

@ -207,20 +207,6 @@ export default abstract class AbstractDriver {
);
await this.DisconnectFromServer();
dbModel = AbstractDriver.FindManyToManyRelations(dbModel);
dbModel = AbstractDriver.FindFileImports(dbModel);
return dbModel;
}
private static FindFileImports(dbModel: Entity[]) {
dbModel.forEach(entity => {
entity.relations.forEach(relation => {
if (
!entity.fileImports.some(v => v === relation.relatedTable)
) {
entity.fileImports.push(relation.relatedTable);
}
});
});
return dbModel;
}