不要怂,就是干,撸起袖子干!

Commit f958066a by Mick Hansen

don't set previous value in loop if raw

1 parent 73f08f8f
Showing with 5 additions and 5 deletions
...@@ -13,8 +13,6 @@ module.exports = (function() { ...@@ -13,8 +13,6 @@ module.exports = (function() {
this._previousDataValues = {} this._previousDataValues = {}
this.__options = this.Model.options this.__options = this.Model.options
this.options = options this.options = options
this.hasPrimaryKeys = this.Model.options.hasPrimaryKeys
this.__eagerlyLoadedAssociations = []
this.isNewRecord = options.isNewRecord this.isNewRecord = options.isNewRecord
initValues.call(this, values, options); initValues.call(this, values, options);
...@@ -161,7 +159,9 @@ module.exports = (function() { ...@@ -161,7 +159,9 @@ module.exports = (function() {
} }
} else { } else {
options || (options = {}) options || (options = {})
originalValue = this.dataValues[key] if (!options.raw) {
originalValue = this.dataValues[key]
}
// If not raw, and there's a customer setter // If not raw, and there's a customer setter
if (!options.raw && this._customSetters[key]) { if (!options.raw && this._customSetters[key]) {
...@@ -180,7 +180,7 @@ module.exports = (function() { ...@@ -180,7 +180,7 @@ module.exports = (function() {
} }
// If attempting to set primary key and primary key is already defined, return // If attempting to set primary key and primary key is already defined, return
if (this.Model._hasPrimaryKeys && originalValue && this.Model._isPrimaryKey(key)) { if (!options.raw && this.Model._hasPrimaryKeys && originalValue && this.Model._isPrimaryKey(key)) {
return return
} }
...@@ -199,7 +199,7 @@ module.exports = (function() { ...@@ -199,7 +199,7 @@ module.exports = (function() {
value = new Date(value) value = new Date(value)
} }
if (originalValue !== value) { if (!options.raw && originalValue !== value) {
this._previousDataValues[key] = originalValue this._previousDataValues[key] = originalValue
} }
this.dataValues[key] = value this.dataValues[key] = value
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!