Not clear oneWay relation on model update fix #1477

This commit is contained in:
Jim LAURIE 2018-07-02 15:41:53 +02:00
parent cd41c663e6
commit eff46b5cb1
2 changed files with 4 additions and 4 deletions

View File

@ -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 }]);

View File

@ -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)) {