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

Commit cfd0db95 by Mick Hansen

don't attempt to check for or convert dates if raw, date conversion from the db …

…is currently handled in the drivers
1 parent 33033572
Showing with 19 additions and 16 deletions
......@@ -174,19 +174,27 @@ module.exports = (function() {
this._setInclude(key, value, options)
return
} else {
// If not raw, and attribute is not in model definition, return
if (!options.raw && !this._isAttribute(key)) {
return;
}
// Bunch of stuff we won't do when its raw
if (!options.raw) {
// If attribute is not in model definition, return
if (!this._isAttribute(key)) {
return;
}
// If attempting to set primary key and primary key is already defined, return
if (!options.raw && this.Model._hasPrimaryKeys && originalValue && this.Model._isPrimaryKey(key)) {
return
}
// If attempting to set primary key and primary key is already defined, return
if (this.Model._hasPrimaryKeys && originalValue && this.Model._isPrimaryKey(key)) {
return
}
// If attempting to set read only attributes, return
if (!options.raw && this.Model._hasReadOnlyAttributes && this.Model._isReadOnlyAttribute(key)) {
return
// If attempting to set read only attributes, return
if (this.Model._hasReadOnlyAttributes && this.Model._isReadOnlyAttribute(key)) {
return
}
// Convert date fields to real date objects
if (this.Model._hasDateAttributes && this.Model._isDateAttribute(key) && value !== null && !(value instanceof Date)) {
value = new Date(value)
}
}
// Convert boolean-ish values to booleans
......@@ -194,11 +202,6 @@ module.exports = (function() {
value = !!value
}
// Convert date fields to real date objects
if (this.Model._hasDateAttributes && this.Model._isDateAttribute(key) && value !== null && !(value instanceof Date)) {
value = new Date(value)
}
if (!options.raw && originalValue !== value) {
this._previousDataValues[key] = originalValue
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!