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

Commit 42988bf2 by Sascha Gehlich

Bugfix: Make sure DAO#find() takes `transaction` option in first parameter

1 parent e1031475
Showing with 21 additions and 2 deletions
...@@ -536,7 +536,7 @@ module.exports = (function() { ...@@ -536,7 +536,7 @@ module.exports = (function() {
plain: true, plain: true,
type: 'SELECT', type: 'SELECT',
hasJoin: hasJoin hasJoin: hasJoin
}, queryOptions)) }, queryOptions, { transaction: (options || {}).transaction }))
} }
DAOFactory.prototype.aggregate = function(field, aggregateFunction, options) { DAOFactory.prototype.aggregate = function(field, aggregateFunction, options) {
......
...@@ -236,7 +236,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -236,7 +236,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
paranoid: true, paranoid: true,
underscored: true underscored: true
}) })
UserTable.sync({force: true}).success(function() { UserTable.sync({force: true}).success(function() {
UserTable.create({aNumber: 30}).success(function(user) { UserTable.create({aNumber: 30}).success(function(user) {
UserTable.count().success(function(c) { UserTable.count().success(function(c) {
...@@ -466,6 +466,25 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -466,6 +466,25 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
describe('find', function() {
it.only('supports the transaction option in the first parameter', function(done) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING, foo: Sequelize.STRING })
User.sync({ force: true }).success(function() {
sequelize.transaction(function(t) {
User.create({ username: 'foo' }, { transaction: t }).success(function() {
User.find({ where: { username: 'foo' }, transaction: t }).success(function(user) {
expect(user).to.not.be.null
t.rollback().success(function() { done() })
})
})
})
})
})
})
})
describe('findOrInitialize', function() { describe('findOrInitialize', function() {
it('supports transactions', function(done) { it('supports transactions', function(done) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { Support.prepareTransactionTest(this.sequelize, function(sequelize) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!