Skip to content

Commit

Permalink
Merge pull request #1092 from strapi/upload/bookshelf
Browse files Browse the repository at this point in the history
Fix loosing of morph relations on update in CM with Bookshelf
  • Loading branch information
lauriejim committed May 3, 2018
2 parents 899faec + 902ea63 commit 750167a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ module.exports = {
}

if (association.type === 'model' || (association.type === 'collection' && _.isObject(array))) {
return _.isEmpty(array) ? [] : transformToArrayID([array]);
return _.isEmpty(_.toString(array)) ? [] : transformToArrayID([array]);
}

return [];
Expand Down
2 changes: 1 addition & 1 deletion packages/strapi-utils/lib/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = {
// We have to find if they are a model linked to this key
_.forIn(allModels, model => {
_.forIn(model.attributes, attribute => {
if (attribute.hasOwnProperty('via') && attribute.via === key) {
if (attribute.hasOwnProperty('via') && attribute.via === key && attribute.model === currentModelName) {
if (attribute.hasOwnProperty('collection')) {
types.other = 'collection';

Expand Down

0 comments on commit 750167a

Please sign in to comment.