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

Commit 20563ff0 by Sascha Depold

transaction support for update

1 parent e9dc214a
...@@ -502,7 +502,7 @@ module.exports = (function() { ...@@ -502,7 +502,7 @@ module.exports = (function() {
return new Utils.CustomEventEmitter(function(emitter) { return new Utils.CustomEventEmitter(function(emitter) {
var chainer = new Utils.QueryChainer() var chainer = new Utils.QueryChainer()
chainer.add(self, 'queryAndEmit', [sql, 'bulkUpdate']) chainer.add(self, 'queryAndEmit', [[sql, null, options], 'bulkUpdate'])
return chainer.runSerially() return chainer.runSerially()
.success(function(results){ .success(function(results){
......
...@@ -1254,6 +1254,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1254,6 +1254,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('update', function() { describe('update', function() {
it('supports transactions', function(done) {
Support.prepareTransactionTest(dialect, this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function() {
sequelize.transaction(function(t) {
User.update({ username: 'bar' }, {}, { transaction: t }).success(function() {
User.all().success(function(users1) {
User.all({ transaction: t }).success(function(users2) {
expect(users1[0].username).to.equal('foo')
expect(users2[0].username).to.equal('bar')
t.rollback().success(done)
})
})
})
})
})
})
})
})
it('updates the attributes that we select only without updating createdAt', function(done) { it('updates the attributes that we select only without updating createdAt', function(done) {
var User = this.sequelize.define('User1', { var User = this.sequelize.define('User1', {
username: Sequelize.STRING, username: Sequelize.STRING,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!