Import regression fix (in "next") (#224)

Import regression fix (in "next")
This commit is contained in:
Kononnable 2019-11-17 15:05:38 +01:00 committed by GitHub
commit 3da7cf22cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -128,10 +128,26 @@ function removeColumnDefaultProperties(
});
return dbModel;
}
function findFileImports(dbModel: Entity[]) {
dbModel.forEach(entity => {
entity.relations.forEach(relation => {
if (
relation.relatedTable !== entity.tscName &&
!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;
}