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

Commit 4cf1cc77 by Mick Hansen

fix hooks

1 parent eb77dfb9
...@@ -223,7 +223,6 @@ module.exports = (function() { ...@@ -223,7 +223,6 @@ module.exports = (function() {
} }
if (type === 'set') { if (type === 'set') {
funcs[attribute] = function(value) { funcs[attribute] = function(value) {
console.log(this)
return this.set(attribute, value) return this.set(attribute, value)
} }
} }
......
...@@ -246,20 +246,20 @@ module.exports = (function() { ...@@ -246,20 +246,20 @@ module.exports = (function() {
options.fields.push(createdAtAttr) options.fields.push(createdAtAttr)
} }
} }
var tmpVals = self.dataValues
options.fields.forEach(function(field) {
if (tmpVals[field] !== undefined) {
values[field] = tmpVals[field]
}
})
} }
return new Utils.CustomEventEmitter(function(emitter) { return new Utils.CustomEventEmitter(function(emitter) {
self.hookValidate().error(function(err) { self.hookValidate().error(function(err) {
emitter.emit('error', err) emitter.emit('error', err)
}).success(function() { }).success(function() {
var tmpVals = self.dataValues
options.fields.forEach(function(field) {
if (tmpVals[field] !== undefined) {
values[field] = tmpVals[field]
}
})
for (var attrName in self.daoFactory.rawAttributes) { for (var attrName in self.daoFactory.rawAttributes) {
if (self.daoFactory.rawAttributes.hasOwnProperty(attrName)) { if (self.daoFactory.rawAttributes.hasOwnProperty(attrName)) {
var definition = self.daoFactory.rawAttributes[attrName] var definition = self.daoFactory.rawAttributes[attrName]
......
...@@ -713,8 +713,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -713,8 +713,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect(users[0].secretValue).to.be.null expect(users[0].secretValue).to.be.null
done() done()
}) })
}).on('sql', function (sql) {
console.log(sql)
}) })
}) })
......
...@@ -23,6 +23,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -23,6 +23,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
}, { }, {
hooks: { hooks: {
beforeValidate: function(user, fn) { beforeValidate: function(user, fn) {
console.log("beforeValidate")
user.mood = 'happy' user.mood = 'happy'
fn(null, user) fn(null, user)
}, },
...@@ -111,7 +112,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -111,7 +112,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
self.User.all().success(function(users) { self.User.all().success(function(users) {
expect(users[0].mood).to.equal('happy') expect(users[0].mood).to.equal('happy')
expect(users[0].mood).to.equal('happy') expect(users[1].mood).to.equal('happy')
done() done()
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!