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

Commit ea1b5dbb by Sascha Depold

Merge branch 'master' of https://github.com/tonyd256/sequelize into tonyd256-master

2 parents a3dc7819 b192fd79
Showing with 9 additions and 8 deletions
...@@ -122,6 +122,14 @@ module.exports = (function() { ...@@ -122,6 +122,14 @@ module.exports = (function() {
}) })
} }
var errors = this.validate()
if (!!errors) {
return new Utils.CustomEventEmitter(function(emitter) {
emitter.emit('error', errors)
}).run()
}
for (var attrName in this.daoFactory.rawAttributes) { for (var attrName in this.daoFactory.rawAttributes) {
if (this.daoFactory.rawAttributes.hasOwnProperty(attrName)) { if (this.daoFactory.rawAttributes.hasOwnProperty(attrName)) {
var definition = this.daoFactory.rawAttributes[attrName] var definition = this.daoFactory.rawAttributes[attrName]
...@@ -160,14 +168,7 @@ module.exports = (function() { ...@@ -160,14 +168,7 @@ module.exports = (function() {
this.dataValues[updatedAtAttr] = values[updatedAtAttr] = Utils.now(this.sequelize.options.dialect) this.dataValues[updatedAtAttr] = values[updatedAtAttr] = Utils.now(this.sequelize.options.dialect)
} }
var errors = this.validate() if (this.isNewRecord) {
if (!!errors) {
return new Utils.CustomEventEmitter(function(emitter) {
emitter.emit('error', errors)
}).run()
}
else if (this.isNewRecord) {
this.isDirty = false this.isDirty = false
return this.QueryInterface.insert(this, this.QueryInterface.QueryGenerator.addSchema(this.__factory), values) return this.QueryInterface.insert(this, this.QueryInterface.QueryGenerator.addSchema(this.__factory), values)
} else { } else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!