mirror of
https://github.com/strapi/strapi.git
synced 2025-09-04 14:23:03 +00:00
feat: compute omitIds
This commit is contained in:
parent
49f290ff97
commit
4d79a359bd
@ -1233,7 +1233,6 @@ const createEntityManager = (db) => {
|
||||
},
|
||||
|
||||
// TODO: Clone polymorphic relations
|
||||
// TODO: Excluded relation attributes
|
||||
/**
|
||||
*
|
||||
* @param {string} uid - uid of the entity to clone
|
||||
@ -1276,8 +1275,23 @@ const createEntityManager = (db) => {
|
||||
return;
|
||||
}
|
||||
|
||||
let omitIds = [];
|
||||
if (has(attrName, data)) {
|
||||
const cleanRelationData = toAssocs(data[attrName]);
|
||||
|
||||
// Don't clone if the relation attr is being set
|
||||
if (cleanRelationData.set) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disconnected relations don't need to be cloned
|
||||
if (cleanRelationData.disconnect) {
|
||||
omitIds = toIds(cleanRelationData.disconnect);
|
||||
}
|
||||
}
|
||||
|
||||
if (isOneToAny(attribute) && isBidirectional(attribute)) {
|
||||
await replaceRegularRelations({ targetId, sourceId, attribute, transaction });
|
||||
await replaceRegularRelations({ targetId, sourceId, attribute, omitIds, transaction });
|
||||
} else {
|
||||
await cloneRegularRelations({ targetId, sourceId, attribute, transaction });
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user