mirror of
https://github.com/strapi/strapi.git
synced 2025-08-19 22:27:18 +00:00
Not clear oneWay relation on model update fix #1477
This commit is contained in:
parent
cd41c663e6
commit
eff46b5cb1
@ -169,7 +169,7 @@ module.exports = {
|
||||
|
||||
strapi.reload.isWatching = false;
|
||||
|
||||
const clearRelationsErrors = Service.clearRelations(model);
|
||||
const clearRelationsErrors = Service.clearRelations(model, undefined, true);
|
||||
|
||||
if (!_.isEmpty(clearRelationsErrors)) {
|
||||
return ctx.badRequest(null, [{ messages: clearRelationsErrors }]);
|
||||
|
@ -241,7 +241,7 @@ module.exports = {
|
||||
return [attributesNotConfigurable, errors];
|
||||
},
|
||||
|
||||
clearRelations: (model, source) => {
|
||||
clearRelations: (model, source, force) => {
|
||||
const errors = [];
|
||||
const structure = {
|
||||
models: strapi.models,
|
||||
@ -259,10 +259,10 @@ module.exports = {
|
||||
Object.keys(models).forEach(name => {
|
||||
const relationsToDelete = _.get(plugin ? strapi.plugins[plugin].models[name] : strapi.models[name], 'associations', []).filter(association => {
|
||||
if (source) {
|
||||
return association[association.type] === model && association.plugin === source;
|
||||
return association[association.type] === model && association.plugin === source && (association.nature !== 'oneWay' || force);
|
||||
}
|
||||
|
||||
return association[association.type] === model;
|
||||
return association[association.type] === model && (association.nature !== 'oneWay' || force);
|
||||
});
|
||||
|
||||
if (!_.isEmpty(relationsToDelete)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user