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

Commit 673cf643 by Lukas Spieß Committed by Sushant

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

Because the query type was not properly set when doing a soft delete, Sequelize tried to format the result in the wrong format.
1 parent f191bd3b
......@@ -19,6 +19,8 @@
- [FIXED] Issue with overrriding custom methods with association mixins (all association methods are now exposed) [#6682](https://github.com/sequelize/sequelize/issues/6682)
- [ADDED] Support condition objects in utility functions [#6685](https://github.com/sequelize/sequelize/pull/6685)
- [FIXED] HSTORE and JSON fields being renamed when `options.field` is specified on a matching model attribute
- [FIXED] Soft-delete not returning number of affected rows on mssql [#6930](https://github.com/sequelize/sequelize/pull/6930)
## BC breaks:
- `DATEONLY` now returns string in `YYYY-MM-DD` format rather than `Date` type
......
......@@ -2380,6 +2380,9 @@ class Model {
}).then(() => {
// Run delete query (or update if paranoid)
if (this._timestampAttributes.deletedAt && !options.force) {
// Set query type appropriately when running soft delete
options.type = QueryTypes.BULKUPDATE;
const attrValueHash = {};
const deletedAtAttribute = this.rawAttributes[this._timestampAttributes.deletedAt];
const field = this.rawAttributes[this._timestampAttributes.deletedAt].field;
......
......@@ -38,7 +38,10 @@ describe(Support.getTestDialectTeaser('Model'), function () {
.then(() => Account.count())
.then((count) => {
expect(count).to.be.equal(1);
return Account.destroy({ where: { ownerId: 12 }});
return Account.destroy({ where: { ownerId: 12 }})
.then((result) => {
expect(result).to.be.equal(1);
});
})
.then(() => Account.count())
.then((count) => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!