diff --git a/libs/common/src/modules/space-model/entities/subspace-model/subspace-model.entity.ts b/libs/common/src/modules/space-model/entities/subspace-model/subspace-model.entity.ts index e1d0be0..f5f6377 100644 --- a/libs/common/src/modules/space-model/entities/subspace-model/subspace-model.entity.ts +++ b/libs/common/src/modules/space-model/entities/subspace-model/subspace-model.entity.ts @@ -6,7 +6,6 @@ import { SubspaceEntity } from '@app/common/modules/space/entities'; import { TagModel } from '../tag-model.entity'; @Entity({ name: 'subspace-model' }) -@Unique(['subspaceName', 'spaceModel']) export class SubspaceModelEntity extends AbstractEntity { @Column({ type: 'uuid', diff --git a/src/space-model/services/subspace/subspace-model.service.ts b/src/space-model/services/subspace/subspace-model.service.ts index e045f36..f309856 100644 --- a/src/space-model/services/subspace/subspace-model.service.ts +++ b/src/space-model/services/subspace/subspace-model.service.ts @@ -310,6 +310,7 @@ export class SubSpaceModelService { spaceModel: { uuid: spaceModelUuid, }, + disabled: false, ...(excludeUuid && { uuid: Not(excludeUuid) }), }, }); diff --git a/src/space-model/services/tag-model.service.ts b/src/space-model/services/tag-model.service.ts index c364816..14f2cf2 100644 --- a/src/space-model/services/tag-model.service.ts +++ b/src/space-model/services/tag-model.service.ts @@ -67,20 +67,25 @@ export class TagModelService { try { const existingTag = await this.getTagByUuid(tag.uuid); - if (spaceModel) { - await this.checkTagReuse(tag.tag, existingTag.product.uuid, spaceModel); - } else { - await this.checkTagReuse( - tag.tag, - existingTag.product.uuid, - subspaceModel.spaceModel, - ); - } + if (tag.tag !== existingTag.tag) { + if (spaceModel) { + await this.checkTagReuse( + tag.tag, + existingTag.product.uuid, + spaceModel, + ); + } else { + await this.checkTagReuse( + tag.tag, + existingTag.product.uuid, + subspaceModel.spaceModel, + ); + } - if (tag.tag) { - existingTag.tag = tag.tag; + if (tag.tag) { + existingTag.tag = tag.tag; + } } - return await queryRunner.manager.save(existingTag); } catch (error) { if (error instanceof HttpException) { @@ -217,7 +222,10 @@ export class TagModelService { }); if (tagExists) { - throw new HttpException(`Tag can't be reused`, HttpStatus.CONFLICT); + throw new HttpException( + `Tag ${tag} can't be reused`, + HttpStatus.CONFLICT, + ); } } catch (error) { if (error instanceof HttpException) {