Skip to content

Commit 0713eec

Browse files
author
Alexander Kharkovey
committed
test(json-api-sdk): fix test
1 parent a04e765 commit 0713eec

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libs/json-api/src/lib/mixins/service/service.mixin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ export function serviceMixin(entity: Entity, transform: TransformMixin, connecti
477477

478478
await builderDeleteRelationships.addAndRemove(idsToAdd, idsToDelete);
479479

480-
if (relationObject.relationType === 'many-to-many') {
480+
if (relationObject.relationType === 'many-to-many' && (body as BaseData[]).some(i => i.attributes)) {
481481
const repoTarget = this.repository.manager.getRepository<EntitySchema>(relationObject.junctionEntityMetadata.target);
482482
const currentData = await repoTarget.find({
483483
where: {
@@ -590,7 +590,7 @@ export function serviceMixin(entity: Entity, transform: TransformMixin, connecti
590590
const { id } = Array.isArray(body) ? body.shift() : body;
591591
await postBuilder.set(id);
592592
}
593-
if (relations.relationType === 'many-to-many') {
593+
if (relations.relationType === 'many-to-many' && (body as BaseData[]).some(item => item.attributes)) {
594594
const repoTarget = this.repository.manager.getRepository<EntitySchema>(relations.junctionEntityMetadata.target);
595595
const currentData = await repoTarget.find({
596596
where: {

0 commit comments

Comments
 (0)