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

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 12 additions and 9 deletions
...@@ -174,30 +174,33 @@ module.exports = (function() { ...@@ -174,30 +174,33 @@ module.exports = (function() {
this._setInclude(key, value, options) this._setInclude(key, value, options)
return return
} else { } else {
// If not raw, and attribute is not in model definition, return // Bunch of stuff we won't do when its raw
if (!options.raw && !this._isAttribute(key)) { if (!options.raw) {
// If attribute is not in model definition, return
if (!this._isAttribute(key)) {
return; return;
} }
// 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 (!options.raw && this.Model._hasPrimaryKeys && originalValue && this.Model._isPrimaryKey(key)) { if (this.Model._hasPrimaryKeys && originalValue && this.Model._isPrimaryKey(key)) {
return return
} }
// If attempting to set read only attributes, return // If attempting to set read only attributes, return
if (!options.raw && this.Model._hasReadOnlyAttributes && this.Model._isReadOnlyAttribute(key)) { if (this.Model._hasReadOnlyAttributes && this.Model._isReadOnlyAttribute(key)) {
return return
} }
// Convert boolean-ish values to booleans
if (this.Model._hasBooleanAttributes && this.Model._isBooleanAttribute(key) && value !== null && value !== undefined) {
value = !!value
}
// Convert date fields to real date objects // Convert date fields to real date objects
if (this.Model._hasDateAttributes && this.Model._isDateAttribute(key) && value !== null && !(value instanceof Date)) { if (this.Model._hasDateAttributes && this.Model._isDateAttribute(key) && value !== null && !(value instanceof Date)) {
value = new Date(value) value = new Date(value)
} }
}
// Convert boolean-ish values to booleans
if (this.Model._hasBooleanAttributes && this.Model._isBooleanAttribute(key) && value !== null && value !== undefined) {
value = !!value
}
if (!options.raw && originalValue !== value) { if (!options.raw && originalValue !== value) {
this._previousDataValues[key] = originalValue 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!