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

Commit 33becdf7 by Mick Hansen

Merge pull request #2404 from suisha/1.7.0

Include options when calling destroy on a paranoid table
2 parents 3563869b 75d8e353
Showing with 24 additions and 2 deletions
...@@ -994,7 +994,7 @@ module.exports = (function() { ...@@ -994,7 +994,7 @@ module.exports = (function() {
var attrValueHash = {} var attrValueHash = {}
attrValueHash[self._timestampAttributes.deletedAt] = Utils.now() attrValueHash[self._timestampAttributes.deletedAt] = Utils.now()
query = 'bulkUpdate' query = 'bulkUpdate'
args = [self.tableName, attrValueHash, where] args = [self.tableName, attrValueHash, where, options]
} else { } else {
query = 'bulkDelete' query = 'bulkDelete'
args = [self.tableName, where, options] args = [self.tableName, where, options]
......
...@@ -791,7 +791,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -791,7 +791,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('destroy', function() { describe('destroy', function() {
it('supports transactions', function(done) { it('supports transactions for non-paranoid tables', function(done) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING }) var User = sequelize.define('User', { username: Sequelize.STRING })
...@@ -813,6 +813,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -813,6 +813,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('supports transactions for paranoid tables', function(done) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING }, { paranoid: true })
User.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function() {
sequelize.transaction(function(t) {
User.destroy({}, { transaction: t }).success(function() {
User.count().success(function(count1) {
User.count({ transaction: t }).success(function(count2) {
expect(count1).to.equal(1)
expect(count2).to.equal(0)
t.rollback().success(function(){ done() })
})
})
})
})
})
})
})
})
it('deletes values that match filter', function(done) { it('deletes values that match filter', function(done) {
var self = this var self = this
, data = [{ username: 'Peter', secretValue: '42' }, , data = [{ username: 'Peter', secretValue: '42' },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!