Skip to content

Commit 33becdf

Browse files
committed
Merge pull request #2404 from suisha/1.7.0
Include options when calling destroy on a paranoid table
2 parents 3563869 + 75d8e35 commit 33becdf

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/dao-factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ module.exports = (function() {
994994
var attrValueHash = {}
995995
attrValueHash[self._timestampAttributes.deletedAt] = Utils.now()
996996
query = 'bulkUpdate'
997-
args = [self.tableName, attrValueHash, where]
997+
args = [self.tableName, attrValueHash, where, options]
998998
} else {
999999
query = 'bulkDelete'
10001000
args = [self.tableName, where, options]

test/dao-factory.test.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
791791
})
792792

793793
describe('destroy', function() {
794-
it('supports transactions', function(done) {
794+
it('supports transactions for non-paranoid tables', function(done) {
795795
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
796796
var User = sequelize.define('User', { username: Sequelize.STRING })
797797

@@ -813,6 +813,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
813813
})
814814
})
815815

816+
it('supports transactions for paranoid tables', function(done) {
817+
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
818+
var User = sequelize.define('User', { username: Sequelize.STRING }, { paranoid: true })
819+
820+
User.sync({ force: true }).success(function() {
821+
User.create({ username: 'foo' }).success(function() {
822+
sequelize.transaction(function(t) {
823+
User.destroy({}, { transaction: t }).success(function() {
824+
User.count().success(function(count1) {
825+
User.count({ transaction: t }).success(function(count2) {
826+
expect(count1).to.equal(1)
827+
expect(count2).to.equal(0)
828+
t.rollback().success(function(){ done() })
829+
})
830+
})
831+
})
832+
})
833+
})
834+
})
835+
})
836+
})
837+
816838
it('deletes values that match filter', function(done) {
817839
var self = this
818840
, data = [{ username: 'Peter', secretValue: '42' },

0 commit comments

Comments
 (0)