0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Added db formatter for settings model

refs #10582

- ensure we won't forward booleans to database
- type TEXT will transform booleans to "0"/"1!
This commit is contained in:
kirrg001 2019-03-07 12:17:21 +01:00 committed by Katharina Irrgang
parent 037ac4d748
commit bfccaa8d2e

View file

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