Skip to content

Commit

Permalink
Added db formatter for settings model
Browse files Browse the repository at this point in the history
refs TryGhost#10582

- ensure we won't forward booleans to database
- type TEXT will transform booleans to "0"/"1!
  • Loading branch information
kirrg001 committed Mar 11, 2019
1 parent 037ac4d commit bfccaa8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/server/models/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ Settings = ghostBookshelf.Model.extend({
});
},

format() {
const attrs = ghostBookshelf.Model.prototype.format.apply(this, arguments);

// @NOTE: type TEXT will transform boolean to "0"
if (_.isBoolean(attrs.value)) {
attrs.value = attrs.value.toString();
}

return attrs;
},

parse() {
const attrs = ghostBookshelf.Model.prototype.parse.apply(this, arguments);

Expand Down

0 comments on commit bfccaa8

Please sign in to comment.