mirror of
https://github.com/strapi/strapi.git
synced 2025-08-20 22:59:11 +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;
|
strapi.reload.isWatching = false;
|
||||||
|
|
||||||
const clearRelationsErrors = Service.clearRelations(model);
|
const clearRelationsErrors = Service.clearRelations(model, undefined, true);
|
||||||
|
|
||||||
if (!_.isEmpty(clearRelationsErrors)) {
|
if (!_.isEmpty(clearRelationsErrors)) {
|
||||||
return ctx.badRequest(null, [{ messages: clearRelationsErrors }]);
|
return ctx.badRequest(null, [{ messages: clearRelationsErrors }]);
|
||||||
|
@ -241,7 +241,7 @@ module.exports = {
|
|||||||
return [attributesNotConfigurable, errors];
|
return [attributesNotConfigurable, errors];
|
||||||
},
|
},
|
||||||
|
|
||||||
clearRelations: (model, source) => {
|
clearRelations: (model, source, force) => {
|
||||||
const errors = [];
|
const errors = [];
|
||||||
const structure = {
|
const structure = {
|
||||||
models: strapi.models,
|
models: strapi.models,
|
||||||
@ -259,10 +259,10 @@ module.exports = {
|
|||||||
Object.keys(models).forEach(name => {
|
Object.keys(models).forEach(name => {
|
||||||
const relationsToDelete = _.get(plugin ? strapi.plugins[plugin].models[name] : strapi.models[name], 'associations', []).filter(association => {
|
const relationsToDelete = _.get(plugin ? strapi.plugins[plugin].models[name] : strapi.models[name], 'associations', []).filter(association => {
|
||||||
if (source) {
|
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)) {
|
if (!_.isEmpty(relationsToDelete)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user