From da80019acab19144b611cb3571217c3248b3abcc Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Thu, 5 Apr 2018 16:24:35 +0200 Subject: [PATCH] Removed taking care of bookshelf's changed model keys no issue - this is no longer needed for now - it was anyway a little bit ugly to modify bookshelf's `changed` object - if we want to change something about figuring out if a model has changed (including relations) -> we probably need to override bookshelf --- core/server/models/base/index.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/core/server/models/base/index.js b/core/server/models/base/index.js index c5471373c7f9..45150c1343f8 100644 --- a/core/server/models/base/index.js +++ b/core/server/models/base/index.js @@ -180,18 +180,6 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({ this.attributes = this.pick(this.permittedAttributes()); // Store the previous attributes so we can tell what was updated later this._updatedAttributes = newObj.previousAttributes(); - - /** - * Bookshelf keeps none valid model attributes in `model.changed`. This causes problems - * when detecting if a model has changed. Bookshelf detects changed attributes too early. - * So we have to manually remove invalid model attributes from this object. - * - * e.g. if you pass `tag.parent` into the model layer, but the value has not changed, - * the attribute (`tag.parent`) is still kept in the `changed` object. This is wrong. - * - * TLDR; only keep valid model attributes in the changed object - */ - this.changed = _.pick(this.changed, Object.keys(this.attributes)); }, /**