mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
check if set is empty
This commit is contained in:
parent
3e60852fa0
commit
9edb46c310
@ -416,6 +416,10 @@ const createEntityManager = (db) => {
|
||||
|
||||
const { idColumn, typeColumn } = morphColumn;
|
||||
|
||||
if (isEmpty(cleanRelationData.set)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const rows = cleanRelationData.set.map((data, idx) => {
|
||||
return {
|
||||
[joinColumn.name]: data.id,
|
||||
@ -428,10 +432,6 @@ const createEntityManager = (db) => {
|
||||
};
|
||||
});
|
||||
|
||||
if (isEmpty(rows)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
await this.createQueryBuilder(joinTable.name).insert(rows).execute();
|
||||
}
|
||||
|
||||
@ -445,6 +445,10 @@ const createEntityManager = (db) => {
|
||||
|
||||
const { idColumn, typeColumn, typeField = '__type' } = morphColumn;
|
||||
|
||||
if (isEmpty(cleanRelationData.set)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const rows = cleanRelationData.set.map((data, idx) => ({
|
||||
[joinColumn.name]: id,
|
||||
[idColumn.name]: data.id,
|
||||
@ -454,10 +458,6 @@ const createEntityManager = (db) => {
|
||||
order: idx + 1,
|
||||
}));
|
||||
|
||||
if (isEmpty(rows)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// delete previous relations
|
||||
await deleteRelatedMorphOneRelationsAfterMorphToManyUpdate(rows, {
|
||||
uid,
|
||||
@ -628,6 +628,10 @@ const createEntityManager = (db) => {
|
||||
})
|
||||
.execute();
|
||||
|
||||
if (isEmpty(cleanRelationData.set)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const rows = cleanRelationData.set.map((data, idx) => ({
|
||||
[joinColumn.name]: data.id,
|
||||
[idColumn.name]: id,
|
||||
@ -638,10 +642,6 @@ const createEntityManager = (db) => {
|
||||
field: attributeName,
|
||||
}));
|
||||
|
||||
if (isEmpty(rows)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
await this.createQueryBuilder(joinTable.name).insert(rows).execute();
|
||||
}
|
||||
|
||||
@ -667,6 +667,10 @@ const createEntityManager = (db) => {
|
||||
})
|
||||
.execute();
|
||||
|
||||
if (isEmpty(cleanRelationData.set)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const rows = cleanRelationData.set.map((data, idx) => ({
|
||||
[joinColumn.name]: id,
|
||||
[idColumn.name]: data.id,
|
||||
@ -676,10 +680,6 @@ const createEntityManager = (db) => {
|
||||
order: idx + 1,
|
||||
}));
|
||||
|
||||
if (isEmpty(rows)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// delete previous relations
|
||||
await deleteRelatedMorphOneRelationsAfterMorphToManyUpdate(rows, {
|
||||
uid,
|
||||
|
Loading…
x
Reference in New Issue
Block a user