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

Commit 00cd5214 by Lukas Spieß Committed by Sushant

Fix soft delete not returning affected rows on MSSQL (#6916)

Because the query type was not properly set when doing a soft delete, Sequelize tried to format the result in the wrong format: https://github.com/sequelize/sequelize/blob/cf232e76b46b7cb2fc98c455cc2010d520ca592d/lib/dialects/mssql/query.js#L186
1 parent cf232e76
# Future
- [FIXED] Soft-delete not returning number of affected rows on mssql [#6916](https://github.com/sequelize/sequelize/pull/6916)
# 3.27.0
- [FIXED] Incorrect column name for generateThroughJoin [#6878](https://github.com/sequelize/sequelize/pull/6878)
- [ADDED] Support condition objects in utility functions [#6685](https://github.com/sequelize/sequelize/pull/6685)
......
......@@ -2298,8 +2298,12 @@ Model.prototype.destroy = function(options) {
});
}
}).then(function() {
// Run delete query (or update if paranoid)
if (self._timestampAttributes.deletedAt && !options.force) {
// Set query type appropriately when running soft delete
options.type = QueryTypes.BULKUPDATE;
var attrValueHash = {}
, deletedAtAttribute = self.rawAttributes[self._timestampAttributes.deletedAt]
, field = self.rawAttributes[self._timestampAttributes.deletedAt].field
......
......@@ -38,7 +38,10 @@ describe(Support.getTestDialectTeaser('Model'), function () {
.then(function () { return Account.count(); })
.then(function (count) {
expect(count).to.be.equal(1);
return Account.destroy({ where: { ownerId: 12 }});
return Account.destroy({ where: { ownerId: 12 }})
.then(function (result) {
expect(result).to.be.equal(1);
});
})
.then(function () { return Account.count(); })
.then(function (count) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!