Skip to content

Commit

Permalink
fix: fix hasOne relation with the same table
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
  • Loading branch information
aaqilniz committed Aug 19, 2024
1 parent 30a2d56 commit 8d3a440
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ module.exports = class HasOneRelationGenerator extends BaseRelationGenerator {
);

relationUtils.addProperty(sourceClass, modelProperty);
const imports = relationUtils.getRequiredImports(targetModel, relationType);
const imports = relationUtils.getRequiredImports(
targetModel,
relationType,
sourceModel,
);

relationUtils.addRequiredImports(sourceFile, imports);
await sourceFile.save();
Expand Down Expand Up @@ -159,6 +163,7 @@ module.exports = class HasOneRelationGenerator extends BaseRelationGenerator {
const importsArray = super._getRepositoryRequiredImports(
dstModelClassName,
dstRepositoryClassName,
this.artifactInfo.srcModelClass,
);
importsArray.push({
name: 'HasOneRepositoryFactory',
Expand Down

0 comments on commit 8d3a440

Please sign in to comment.