From 8d3a440dfa3002824a3eba0b72b970e08157d0c6 Mon Sep 17 00:00:00 2001 From: Muhammad Aaqil Date: Sat, 10 Aug 2024 23:29:28 +0500 Subject: [PATCH] fix: fix hasOne relation with the same table Signed-off-by: Muhammad Aaqil --- .../cli/generators/relation/has-one-relation.generator.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/cli/generators/relation/has-one-relation.generator.js b/packages/cli/generators/relation/has-one-relation.generator.js index 0b2008f280e4..2c4585ced1c0 100644 --- a/packages/cli/generators/relation/has-one-relation.generator.js +++ b/packages/cli/generators/relation/has-one-relation.generator.js @@ -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(); @@ -159,6 +163,7 @@ module.exports = class HasOneRelationGenerator extends BaseRelationGenerator { const importsArray = super._getRepositoryRequiredImports( dstModelClassName, dstRepositoryClassName, + this.artifactInfo.srcModelClass, ); importsArray.push({ name: 'HasOneRepositoryFactory',