diff --git a/src/space-model/services/subspace/subspace-model.service.ts b/src/space-model/services/subspace/subspace-model.service.ts index 57e5652..09cf99b 100644 --- a/src/space-model/services/subspace/subspace-model.service.ts +++ b/src/space-model/services/subspace/subspace-model.service.ts @@ -108,7 +108,7 @@ export class SubSpaceModelService { const addDtos = dtos.filter((dto) => dto.action === ModifyAction.ADD); const combinedDtos = dtos.filter((dto) => dto.action !== ModifyAction.ADD); - const deleteDtos = dtos.filter((dto) => dto.action !== ModifyAction.DELETE); + const deleteDtos = dtos.filter((dto) => dto.action === ModifyAction.DELETE); const updatedModels = await this.updateSubspaceModel( combinedDtos, @@ -306,8 +306,6 @@ export class SubSpaceModelService { for (const dto of dtos) { if (!dto.subspaceName) continue; - await this.checkDuplicateNames(dto.subspaceName, spaceModel.uuid); - const existingSubspace = await queryRunner.manager.findOne( this.subspaceModelRepository.target, { where: { uuid: dto.uuid } }, @@ -317,6 +315,9 @@ export class SubSpaceModelService { existingSubspace && existingSubspace.subspaceName !== dto.subspaceName ) { + if (existingSubspace.subspaceName !== dto.subspaceName) { + await this.checkDuplicateNames(dto.subspaceName, spaceModel.uuid); + } existingSubspace.subspaceName = dto.subspaceName; await queryRunner.manager.save(existingSubspace); updatedSubspaces.push({