Moved the import fetching to occur after the naming strategy is applied, to ensure correct imports.
This commit is contained in:
parent
ecf9f51806
commit
91f9f11b44
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user