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

Commit 7d414335 by Mick Hansen

get savehooks working properly, hopefully

1 parent 07b8e9f5
Showing with 9 additions and 4 deletions
......@@ -362,22 +362,26 @@ module.exports = (function() {
// redeclare our new values
values = newValues || values
tmpVals = values
/*tmpVals = values
values = {}
options.fields.forEach(function(field) {
if (tmpVals[field] !== undefined) {
values[field] = tmpVals[field]
}
})
})*/
args[2] = values
// Newest values need to be on the dao since the dao is returned from the query interface
self.dataValues = _.extend(self.dataValues, values)
self.QueryInterface[query].apply(self.QueryInterface, args)
.proxy(emitter, {events: ['sql', 'error']})
.success(function(result) {
values = _.extend(values, result.values) // Transfer database generated values (defaults, autoincrement, etc)
// Transfer database generated values (defaults, autoincrement, etc)
values = _.extend(values, result.values)
// Hook might fail, but since the query succeded the values should be available anyways
// Ensure new values are on DAO, and reset previousDataValues
result.dataValues = _.extend(result.dataValues, values)
result._previousDataValues = _.clone(result.dataValues)
......@@ -387,6 +391,7 @@ module.exports = (function() {
}
if (newValues) {
// Repeat value assignment incase afterHook changed anything
result.dataValues = _.extend(result.dataValues, newValues)
result._previousDataValues = _.clone(result.dataValues)
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!