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

Commit 8a3672c9 by Ruben Bridgewater

Fix transaction not rolling back if no thenable was provided

1 parent e5d1d00d
Showing with 4 additions and 5 deletions
# next # next
- [BUG] Fix regression introduced in 2.1.2: updatedAt not set anymore - [BUG] Fix regression introduced in 2.1.2: updatedAt not set anymore [3667](https://github.com/sequelize/sequelize/pull/3667)
- [BUG] Fix managed transactions not rolling back if no thenable was provided in the transaction block [3667](https://github.com/sequelize/sequelize/pull/3667)
# 2.1.2 # 2.1.2
- [BUG] `Model.create()/update()` no longer attempts to save undefined fields. - [BUG] `Model.create()/update()` no longer attempts to save undefined fields.
......
...@@ -1140,7 +1140,7 @@ module.exports = (function() { ...@@ -1140,7 +1140,7 @@ module.exports = (function() {
} }
var result = autoCallback(transaction); var result = autoCallback(transaction);
if (!result || !result.then) return reject(new Error('You need to return a promise chain/thenable to the sequelize.transaction() callback')); if (!result || !result.then) throw new Error('You need to return a promise chain/thenable to the sequelize.transaction() callback');
return result.then(function (result) { return result.then(function (result) {
return transaction.commit().then(function () { return transaction.commit().then(function () {
...@@ -1148,9 +1148,7 @@ module.exports = (function() { ...@@ -1148,9 +1148,7 @@ module.exports = (function() {
}); });
}); });
}).catch(function(err) { }).catch(function(err) {
transaction.rollback().then(function () { transaction.rollback().finally(function () {
reject(err);
}, function () {
reject(err); reject(err);
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!