소스 검색

fix(cli): Create new instance of entity before saving to db in generated Entity (#3623)

Alexander Berger 6 달 전
부모
커밋
8a2e679749
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      packages/cli/src/commands/add/service/add-service.ts

+ 2 - 1
packages/cli/src/commands/add/service/add-service.ts

@@ -280,7 +280,8 @@ function customizeCreateMethod(serviceClassDeclaration: ClassDeclaration, entity
                             });`);
                             });`);
             } else {
             } else {
                 writer.writeLine(
                 writer.writeLine(
-                    `const newEntity = await this.connection.getRepository(ctx, ${entityRef.name}).save(input);`,
+                    `const newEntityInstance = new ${entityRef.name}(input);
+                    const newEntity = await this.connection.getRepository(ctx, ${entityRef.name}).save(newEntityInstance);`,
                 );
                 );
             }
             }
             if (entityRef.hasCustomFields()) {
             if (entityRef.hasCustomFields()) {