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

Commit 0f4a7b42 by Mick Hansen

Merge branch 'master' of github.com:sequelize/sequelize

2 parents d0453674 38d1887b
...@@ -32,6 +32,7 @@ AbstractDialect.prototype.supports = { ...@@ -32,6 +32,7 @@ AbstractDialect.prototype.supports = {
/* What is the dialect's keyword for INSERT IGNORE */ /* What is the dialect's keyword for INSERT IGNORE */
'IGNORE': '', 'IGNORE': '',
schemas: false, schemas: false,
transactions: true,
constraints: { constraints: {
restrict: true restrict: true
}, },
......
...@@ -25,26 +25,29 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() { ...@@ -25,26 +25,29 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
}) })
describe('getAssociation', function() { describe('getAssociation', function() {
it('supports transactions', function(done) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING })
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING })
Group.belongsTo(User) if (current.dialect.supports.transactions) {
it('supports transactions', function(done) {
sequelize.sync({ force: true }).success(function() { Support.prepareTransactionTest(this.sequelize, function(sequelize) {
User.create({ username: 'foo' }).success(function(user) { var User = sequelize.define('User', { username: Support.Sequelize.STRING })
Group.create({ name: 'bar' }).success(function(group) { , Group = sequelize.define('Group', { name: Support.Sequelize.STRING })
sequelize.transaction().then(function(t) {
group.setUser(user, { transaction: t }).success(function() { Group.belongsTo(User)
Group.all().success(function(groups) {
groups[0].getUser().success(function(associatedUser) { sequelize.sync({ force: true }).success(function() {
expect(associatedUser).to.be.null User.create({ username: 'foo' }).success(function(user) {
Group.all({ transaction: t }).success(function(groups) { Group.create({ name: 'bar' }).success(function(group) {
groups[0].getUser({ transaction: t }).success(function(associatedUser) { sequelize.transaction().then(function(t) {
expect(associatedUser).to.be.not.null group.setUser(user, { transaction: t }).success(function() {
t.rollback().success(function() { Group.all().success(function(groups) {
done() groups[0].getUser().success(function(associatedUser) {
expect(associatedUser).to.be.null
Group.all({ transaction: t }).success(function(groups) {
groups[0].getUser({ transaction: t }).success(function(associatedUser) {
expect(associatedUser).to.be.not.null
t.rollback().success(function() {
done()
})
}) })
}) })
}) })
...@@ -56,7 +59,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() { ...@@ -56,7 +59,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
}) })
}) })
}) })
}) }
it('does not modify the passed arguments', function () { it('does not modify the passed arguments', function () {
var User = this.sequelize.define('user', {}) var User = this.sequelize.define('user', {})
...@@ -126,22 +129,25 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() { ...@@ -126,22 +129,25 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
}) })
describe('setAssociation', function() { describe('setAssociation', function() {
it('supports transactions', function(done) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING })
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING })
Group.belongsTo(User) if (current.dialect.supports.transactions) {
it('supports transactions', function(done) {
sequelize.sync({ force: true }).success(function() { Support.prepareTransactionTest(this.sequelize, function(sequelize) {
User.create({ username: 'foo' }).success(function(user) { var User = sequelize.define('User', { username: Support.Sequelize.STRING })
Group.create({ name: 'bar' }).success(function(group) { , Group = sequelize.define('Group', { name: Support.Sequelize.STRING })
sequelize.transaction().then(function(t) {
group.setUser(user, { transaction: t }).success(function() { Group.belongsTo(User)
Group.all().success(function(groups) {
groups[0].getUser().success(function(associatedUser) { sequelize.sync({ force: true }).success(function() {
expect(associatedUser).to.be.null User.create({ username: 'foo' }).success(function(user) {
t.rollback().success(function() { done() }) Group.create({ name: 'bar' }).success(function(group) {
sequelize.transaction().then(function(t) {
group.setUser(user, { transaction: t }).success(function() {
Group.all().success(function(groups) {
groups[0].getUser().success(function(associatedUser) {
expect(associatedUser).to.be.null
t.rollback().success(function() { done() })
})
}) })
}) })
}) })
...@@ -150,7 +156,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() { ...@@ -150,7 +156,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
}) })
}) })
}) })
}) }
it('can set the association with declared primary keys...', function(done) { it('can set the association with declared primary keys...', function(done) {
var User = this.sequelize.define('UserXYZ', { user_id: {type: DataTypes.INTEGER, primaryKey: true }, username: DataTypes.STRING }) var User = this.sequelize.define('UserXYZ', { user_id: {type: DataTypes.INTEGER, primaryKey: true }, username: DataTypes.STRING })
...@@ -277,24 +283,26 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() { ...@@ -277,24 +283,26 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
}) })
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING }) var User = sequelize.define('User', { username: Support.Sequelize.STRING })
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING })
Group.belongsTo(User) Group.belongsTo(User)
sequelize.sync({ force: true }).success(function() { sequelize.sync({ force: true }).success(function() {
Group.create({ name: 'bar' }).success(function(group) { Group.create({ name: 'bar' }).success(function(group) {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
group.createUser({ username: 'foo' }, { transaction: t }).success(function() { group.createUser({ username: 'foo' }, { transaction: t }).success(function() {
group.getUser().success(function(user) { group.getUser().success(function(user) {
expect(user).to.be.null expect(user).to.be.null
group.getUser({ transaction: t }).success(function(user) { group.getUser({ transaction: t }).success(function(user) {
expect(user).not.to.be.null expect(user).not.to.be.null
t.rollback().success(function() { done() }) t.rollback().success(function() { done() })
})
}) })
}) })
}) })
...@@ -302,7 +310,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() { ...@@ -302,7 +310,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
}) })
}) })
}) })
}) }
}) })
describe("foreign key", function () { describe("foreign key", function () {
......
...@@ -50,43 +50,45 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -50,43 +50,45 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
expect(Object.keys(this.Label.rawAttributes).length).to.equal(3); expect(Object.keys(this.Label.rawAttributes).length).to.equal(3);
}); });
it('supports transactions', function() { if (current.dialect.supports.transactions) {
var Article, Label, sequelize, article, label, t; it('supports transactions', function() {
return Support.prepareTransactionTest(this.sequelize).then(function(_sequelize) { var Article, Label, sequelize, article, label, t;
sequelize = _sequelize; return Support.prepareTransactionTest(this.sequelize).then(function(_sequelize) {
Article = sequelize.define('Article', { 'title': DataTypes.STRING }); sequelize = _sequelize;
Label = sequelize.define('Label', { 'text': DataTypes.STRING }); Article = sequelize.define('Article', { 'title': DataTypes.STRING });
Label = sequelize.define('Label', { 'text': DataTypes.STRING });
Article.hasMany(Label); Article.hasMany(Label);
return sequelize.sync({ force: true }); return sequelize.sync({ force: true });
}).then(function() { }).then(function() {
return Promise.all([ return Promise.all([
Article.create({ title: 'foo' }), Article.create({ title: 'foo' }),
Label.create({ text: 'bar' }) Label.create({ text: 'bar' })
]); ]);
}).spread(function (_article, _label) { }).spread(function (_article, _label) {
article = _article; article = _article;
label = _label; label = _label;
return sequelize.transaction(); return sequelize.transaction();
}).then(function(_t) { }).then(function(_t) {
t = _t; t = _t;
return article.setLabels([ label ], { transaction: t }); return article.setLabels([ label ], { transaction: t });
}).then(function() { }).then(function() {
return Article.all({ transaction: t }); return Article.all({ transaction: t });
}).then(function(articles) { }).then(function(articles) {
return articles[0].hasLabel(label).then(function(hasLabel) { return articles[0].hasLabel(label).then(function(hasLabel) {
expect(hasLabel).to.be.false; expect(hasLabel).to.be.false;
}); });
}).then(function () { }).then(function () {
return Article.all({ transaction: t }); return Article.all({ transaction: t });
}).then(function(articles) { }).then(function(articles) {
return articles[0].hasLabel(label, { transaction: t }).then(function(hasLabel) { return articles[0].hasLabel(label, { transaction: t }).then(function(hasLabel) {
expect(hasLabel).to.be.true; expect(hasLabel).to.be.true;
return t.rollback(); return t.rollback();
});
}); });
}); });
}); }
it('does not have any labels assigned to it initially', function() { it('does not have any labels assigned to it initially', function() {
return Promise.all([ return Promise.all([
...@@ -155,41 +157,43 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -155,41 +157,43 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
return this.sequelize.sync({ force: true }); return this.sequelize.sync({ force: true });
}); });
it('supports transactions', function () { if (current.dialect.supports.transactions) {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) { it('supports transactions', function () {
this.sequelize = sequelize; return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.Article = sequelize.define('Article', { 'title': DataTypes.STRING }); this.sequelize = sequelize;
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING }); this.Article = sequelize.define('Article', { 'title': DataTypes.STRING });
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING });
this.Article.hasMany(this.Label); this.Article.hasMany(this.Label);
return this.sequelize.sync({ force: true }); return this.sequelize.sync({ force: true });
}).then(function () { }).then(function () {
return Promise.all([ return Promise.all([
this.Article.create({ title: 'foo' }), this.Article.create({ title: 'foo' }),
this.Label.create({ text: 'bar' }) this.Label.create({ text: 'bar' })
]); ]);
}).spread(function (article, label) { }).spread(function (article, label) {
this.article = article; this.article = article;
this.label = label; this.label = label;
return this.sequelize.transaction(); return this.sequelize.transaction();
}).then(function(t) { }).then(function(t) {
this.t = t; this.t = t;
return this.article.setLabels([ this.label ], { transaction: t }); return this.article.setLabels([ this.label ], { transaction: t });
}).then(function() { }).then(function() {
return this.Article.all({ transaction: this.t }); return this.Article.all({ transaction: this.t });
}).then(function(articles) { }).then(function(articles) {
return Promise.all([ return Promise.all([
articles[0].hasLabels([ this.label ]), articles[0].hasLabels([ this.label ]),
articles[0].hasLabels([ this.label ], { transaction: this.t }) articles[0].hasLabels([ this.label ], { transaction: this.t })
]); ]);
}).spread(function(hasLabel1, hasLabel2) { }).spread(function(hasLabel1, hasLabel2) {
expect(hasLabel1).to.be.false; expect(hasLabel1).to.be.false;
expect(hasLabel2).to.be.true; expect(hasLabel2).to.be.true;
return this.t.rollback(); return this.t.rollback();
});
}); });
}); }
it('answers false if only some labels have been assigned', function() { it('answers false if only some labels have been assigned', function() {
return Promise.all([ return Promise.all([
...@@ -249,36 +253,39 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -249,36 +253,39 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
}); });
describe('setAssociations', function() { describe('setAssociations', function() {
it('supports transactions', function() {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.Article = sequelize.define('Article', { 'title': DataTypes.STRING });
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING });
this.Article.hasMany(this.Label); if (current.dialect.supports.transactions) {
it('supports transactions', function() {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.Article = sequelize.define('Article', { 'title': DataTypes.STRING });
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING });
this.sequelize = sequelize; this.Article.hasMany(this.Label);
return sequelize.sync({ force: true });
}).then(function() {
return Promise.all([
this.Article.create({ title: 'foo' }),
this.Label.create({ text: 'bar' }),
this.sequelize.transaction()
]);
}).spread(function(article, label, t) {
this.article = article;
this. t = t;
return article.setLabels([ label ], { transaction: t });
}).then(function() {
return this.Label.findAll({ where: { ArticleId: this.article.id }, transaction: undefined });
}).then(function(labels) {
expect(labels.length).to.equal(0);
return this.Label.findAll({ where: { ArticleId: this.article.id }, transaction: this.t }); this.sequelize = sequelize;
}).then(function(labels) { return sequelize.sync({ force: true });
expect(labels.length).to.equal(1); }).then(function() {
return this.t.rollback(); return Promise.all([
this.Article.create({ title: 'foo' }),
this.Label.create({ text: 'bar' }),
this.sequelize.transaction()
]);
}).spread(function(article, label, t) {
this.article = article;
this. t = t;
return article.setLabels([ label ], { transaction: t });
}).then(function() {
return this.Label.findAll({ where: { ArticleId: this.article.id }, transaction: undefined });
}).then(function(labels) {
expect(labels.length).to.equal(0);
return this.Label.findAll({ where: { ArticleId: this.article.id }, transaction: this.t });
}).then(function(labels) {
expect(labels.length).to.equal(1);
return this.t.rollback();
});
}); });
}); }
it("clears associations when passing null to the set-method", function() { it("clears associations when passing null to the set-method", function() {
var User = this.sequelize.define('User', { username: DataTypes.STRING }) var User = this.sequelize.define('User', { username: DataTypes.STRING })
...@@ -366,37 +373,39 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -366,37 +373,39 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
}); });
describe('addAssociations', function() { describe('addAssociations', function() {
it('supports transactions', function() { if (current.dialect.supports.transactions) {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) { it('supports transactions', function() {
this.Article = sequelize.define('Article', { 'title': DataTypes.STRING }); return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING }); this.Article = sequelize.define('Article', { 'title': DataTypes.STRING });
this.Article.hasMany(this.Label); this.Label = sequelize.define('Label', { 'text': DataTypes.STRING });
this.Article.hasMany(this.Label);
this.sequelize = sequelize;
return sequelize.sync({ force: true }); this.sequelize = sequelize;
}).then(function() { return sequelize.sync({ force: true });
return Promise.all([ }).then(function() {
this.Article.create({ title: 'foo' }), return Promise.all([
this.Label.create({ text: 'bar' }) this.Article.create({ title: 'foo' }),
]); this.Label.create({ text: 'bar' })
}).spread(function (article, label) { ]);
this.article = article; }).spread(function (article, label) {
this.label = label; this.article = article;
return this.sequelize.transaction(); this.label = label;
}).then(function (t) { return this.sequelize.transaction();
this.t = t; }).then(function (t) {
return this.article.addLabel(this.label, { transaction: this.t }); this.t = t;
}).then(function () { return this.article.addLabel(this.label, { transaction: this.t });
return this.Label.findAll({ where: { ArticleId: this.article.id }, transaction: undefined }); }).then(function () {
}).then(function (labels) { return this.Label.findAll({ where: { ArticleId: this.article.id }, transaction: undefined });
expect(labels.length).to.equal(0); }).then(function (labels) {
expect(labels.length).to.equal(0);
return this.Label.findAll({ where: { ArticleId: this.article.id }, transaction: this.t });
}).then(function(labels) { return this.Label.findAll({ where: { ArticleId: this.article.id }, transaction: this.t });
expect(labels.length).to.equal(1); }).then(function(labels) {
return this.t.rollback(); expect(labels.length).to.equal(1);
return this.t.rollback();
});
}); });
}); }
it('supports passing the primary key instead of an object', function () { it('supports passing the primary key instead of an object', function () {
var Article = this.sequelize.define('Article', { 'title': DataTypes.STRING }) var Article = this.sequelize.define('Article', { 'title': DataTypes.STRING })
...@@ -521,36 +530,38 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -521,36 +530,38 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
}); });
}); });
it('supports transactions', function() { if (current.dialect.supports.transactions) {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) { it('supports transactions', function() {
this.sequelize = sequelize; return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.Article = sequelize.define('Article', { 'title': DataTypes.STRING }); this.sequelize = sequelize;
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING }); this.Article = sequelize.define('Article', { 'title': DataTypes.STRING });
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING });
this.Article.hasMany(this.Label); this.Article.hasMany(this.Label);
return sequelize.sync({ force: true}); return sequelize.sync({ force: true});
}).then(function () { }).then(function () {
return this.Article.create({ title: 'foo' }); return this.Article.create({ title: 'foo' });
}).then(function(article) { }).then(function(article) {
this.article = article; this.article = article;
return this.sequelize.transaction(); return this.sequelize.transaction();
}).then(function (t) { }).then(function (t) {
this.t = t; this.t = t;
return this.article.createLabel({ text: 'bar' }, { transaction: this.t }); return this.article.createLabel({ text: 'bar' }, { transaction: this.t });
}).then(function() { }).then(function() {
return this.Label.findAll(); return this.Label.findAll();
}).then(function (labels) { }).then(function (labels) {
expect(labels.length).to.equal(0); expect(labels.length).to.equal(0);
return this.Label.findAll({ where: { ArticleId: this.article.id }}); return this.Label.findAll({ where: { ArticleId: this.article.id }});
}).then(function(labels) { }).then(function(labels) {
expect(labels.length).to.equal(0); expect(labels.length).to.equal(0);
return this.Label.findAll({ where: { ArticleId: this.article.id }}, { transaction: this.t }); return this.Label.findAll({ where: { ArticleId: this.article.id }}, { transaction: this.t });
}).then(function(labels) { }).then(function(labels) {
expect(labels.length).to.equal(1); expect(labels.length).to.equal(1);
return this.t.rollback(); return this.t.rollback();
});
}); });
}); }
it('supports passing the field option', function () { it('supports passing the field option', function () {
var Article = this.sequelize.define('Article', { var Article = this.sequelize.define('Article', {
...@@ -774,39 +785,41 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -774,39 +785,41 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
}); });
}); });
it('supports transactions', function() { if (current.dialect.supports.transactions) {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) { it('supports transactions', function() {
this.sequelize = sequelize; return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.Article = sequelize.define('Article', { 'title': DataTypes.STRING }); this.sequelize = sequelize;
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING }); this.Article = sequelize.define('Article', { 'title': DataTypes.STRING });
this.Label = sequelize.define('Label', { 'text': DataTypes.STRING });
this.Article.hasMany(this.Label); this.Article.hasMany(this.Label);
this.Label.hasMany(this.Article); this.Label.hasMany(this.Article);
return sequelize.sync({ force: true }); return sequelize.sync({ force: true });
}).then(function() { }).then(function() {
return Promise.all([ return Promise.all([
this.Article.create({ title: 'foo' }), this.Article.create({ title: 'foo' }),
this.Label.create({ text: 'bar' }), this.Label.create({ text: 'bar' }),
this.sequelize.transaction() this.sequelize.transaction()
]); ]);
}).spread(function (article, label, t) { }).spread(function (article, label, t) {
this.t = t; this.t = t;
return article.setLabels([ label ], { transaction: t }); return article.setLabels([ label ], { transaction: t });
}).then(function() { }).then(function() {
return this.Article.all({ transaction: this.t }); return this.Article.all({ transaction: this.t });
}).then(function(articles) { }).then(function(articles) {
return articles[0].getLabels(); return articles[0].getLabels();
}).then(function(labels) { }).then(function(labels) {
expect(labels).to.have.length(0); expect(labels).to.have.length(0);
return this.Article.all({ transaction: this.t }); return this.Article.all({ transaction: this.t });
}).then(function(articles) { }).then(function(articles) {
return articles[0].getLabels({ transaction: this.t }); return articles[0].getLabels({ transaction: this.t });
}).then(function(labels) { }).then(function(labels) {
expect(labels).to.have.length(1); expect(labels).to.have.length(1);
return this.t.rollback(); return this.t.rollback();
});
}); });
}); }
it('gets all associated objects with all fields', function() { it('gets all associated objects with all fields', function() {
return this.User.find({where: {username: 'John'}}).then(function (john) { return this.User.find({where: {username: 'John'}}).then(function (john) {
...@@ -1095,36 +1108,38 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -1095,36 +1108,38 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
}); });
}); });
it('supports transactions', function() { if (current.dialect.supports.transactions) {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) { it('supports transactions', function() {
this.User = sequelize.define('User', { username: DataTypes.STRING }); return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.Task = sequelize.define('Task', { title: DataTypes.STRING }); this.User = sequelize.define('User', { username: DataTypes.STRING });
this.Task = sequelize.define('Task', { title: DataTypes.STRING });
this.User.hasMany(this.Task); this.User.hasMany(this.Task);
this.Task.hasMany(this.User); this.Task.hasMany(this.User);
this.sequelize = sequelize; this.sequelize = sequelize;
return sequelize.sync({ force: true }); return sequelize.sync({ force: true });
}).then(function() { }).then(function() {
return Promise.all([ return Promise.all([
this.Task.create({ title: 'task' }), this.Task.create({ title: 'task' }),
this.sequelize.transaction() this.sequelize.transaction()
]); ]);
}).spread(function(task, t) { }).spread(function(task, t) {
this.task = task; this.task = task;
this.t = t; this.t = t;
return task.createUser({ username: 'foo' }, { transaction: t }); return task.createUser({ username: 'foo' }, { transaction: t });
}).then(function() { }).then(function() {
return this.task.getUsers(); return this.task.getUsers();
}).then(function(users) { }).then(function(users) {
expect(users).to.have.length(0); expect(users).to.have.length(0);
return this.task.getUsers({ transaction: this.t }); return this.task.getUsers({ transaction: this.t });
}).then(function(users) { }).then(function(users) {
expect(users).to.have.length(1); expect(users).to.have.length(1);
return this.t.rollback(); return this.t.rollback();
});
}); });
}); }
it('supports setting through table attributes', function () { it('supports setting through table attributes', function () {
var User = this.sequelize.define('user', {}) var User = this.sequelize.define('user', {})
...@@ -1207,77 +1222,78 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -1207,77 +1222,78 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
}); });
}); });
it('supports transactions', function() { if (current.dialect.supports.transactions) {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) { it('supports transactions', function() {
this.User = sequelize.define('User', { username: DataTypes.STRING }); return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.Task = sequelize.define('Task', { title: DataTypes.STRING }); this.User = sequelize.define('User', { username: DataTypes.STRING });
this.Task = sequelize.define('Task', { title: DataTypes.STRING });
this.User.hasMany(this.Task); this.User.hasMany(this.Task);
this.Task.hasMany(this.User); this.Task.hasMany(this.User);
this.sequelize = sequelize; this.sequelize = sequelize;
return sequelize.sync({ force: true }); return sequelize.sync({ force: true });
}).then(function() { }).then(function() {
return Promise.all([ return Promise.all([
this.User.create({ username: 'foo' }), this.User.create({ username: 'foo' }),
this.Task.create({ title: 'task' }), this.Task.create({ title: 'task' }),
this.sequelize.transaction() this.sequelize.transaction()
]); ]);
}).spread(function(user, task, t){ }).spread(function(user, task, t){
this.task = task; this.task = task;
this.user = user; this.user = user;
this.t = t; this.t = t;
return task.addUser(user, { transaction: t }); return task.addUser(user, { transaction: t });
}).then(function() { }).then(function() {
return this.task.hasUser(this.user); return this.task.hasUser(this.user);
}).then(function(hasUser) { }).then(function(hasUser) {
expect(hasUser).to.be.false; expect(hasUser).to.be.false;
return this.task.hasUser(this.user, { transaction: this.t }); return this.task.hasUser(this.user, { transaction: this.t });
}).then(function(hasUser) { }).then(function(hasUser) {
expect(hasUser).to.be.true; expect(hasUser).to.be.true;
return this.t.rollback(); return this.t.rollback();
});
}); });
});
it('supports transactions when updating a through model', function() { it('supports transactions when updating a through model', function() {
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) { return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
this.User = sequelize.define('User', { username: DataTypes.STRING }); this.User = sequelize.define('User', { username: DataTypes.STRING });
this.Task = sequelize.define('Task', { title: DataTypes.STRING }); this.Task = sequelize.define('Task', { title: DataTypes.STRING });
this.UserTask = sequelize.define('UserTask', { this.UserTask = sequelize.define('UserTask', {
status: Sequelize.STRING status: Sequelize.STRING
}); });
this.User.hasMany(this.Task, { through: this.UserTask }); this.User.hasMany(this.Task, { through: this.UserTask });
this.Task.hasMany(this.User, { through: this.UserTask }); this.Task.hasMany(this.User, { through: this.UserTask });
this.sequelize = sequelize; this.sequelize = sequelize;
return sequelize.sync({ force: true }); return sequelize.sync({ force: true });
}).then(function() { }).then(function() {
return Promise.all([ return Promise.all([
this.User.create({ username: 'foo' }), this.User.create({ username: 'foo' }),
this.Task.create({ title: 'task' }), this.Task.create({ title: 'task' }),
this.sequelize.transaction({ isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED }) this.sequelize.transaction({ isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED })
]); ]);
}).spread(function(user, task, t){ }).spread(function(user, task, t){
this.task = task; this.task = task;
this.user = user; this.user = user;
this.t = t; this.t = t;
return task.addUser(user, { status: 'pending' }); // Create without transaction, so the old value is accesible from outside the transaction return task.addUser(user, { status: 'pending' }); // Create without transaction, so the old value is accesible from outside the transaction
}).then(function() { }).then(function() {
return this.task.addUser(this.user, { transaction: this.t, status: 'completed' }); // Add an already exisiting user in a transaction, updating a value in the join table return this.task.addUser(this.user, { transaction: this.t, status: 'completed' }); // Add an already exisiting user in a transaction, updating a value in the join table
}).then(function(hasUser) { }).then(function(hasUser) {
return Promise.all([ return Promise.all([
this.user.getTasks(), this.user.getTasks(),
this.user.getTasks({ transaction: this.t }) this.user.getTasks({ transaction: this.t })
]); ]);
}).spread(function(tasks, transactionTasks) { }).spread(function(tasks, transactionTasks) {
expect(tasks[0].UserTask.status).to.equal('pending'); expect(tasks[0].UserTask.status).to.equal('pending');
expect(transactionTasks[0].UserTask.status).to.equal('completed'); expect(transactionTasks[0].UserTask.status).to.equal('completed');
return this.t.rollback(); return this.t.rollback();
});
}); });
}); }
it('supports passing the primary key instead of an object', function () { it('supports passing the primary key instead of an object', function () {
var User = this.sequelize.define('User', { username: DataTypes.STRING }) var User = this.sequelize.define('User', { username: DataTypes.STRING })
......
...@@ -23,28 +23,30 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -23,28 +23,30 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
}) })
describe('getAssocation', function() { describe('getAssocation', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING }) var User = sequelize.define('User', { username: Support.Sequelize.STRING })
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING })
Group.hasOne(User)
Group.hasOne(User)
sequelize.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(fakeUser) { sequelize.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(user) { User.create({ username: 'foo' }).success(function(fakeUser) {
Group.create({ name: 'bar' }).success(function(group) { User.create({ username: 'foo' }).success(function(user) {
sequelize.transaction().then(function(t) { Group.create({ name: 'bar' }).success(function(group) {
group.setUser(user, { transaction: t }).success(function() { sequelize.transaction().then(function(t) {
Group.all().success(function(groups) { group.setUser(user, { transaction: t }).success(function() {
groups[0].getUser().success(function(associatedUser) { Group.all().success(function(groups) {
expect(associatedUser).to.be.null groups[0].getUser().success(function(associatedUser) {
Group.all({ transaction: t }).success(function(groups) { expect(associatedUser).to.be.null
groups[0].getUser({ transaction: t }).success(function(associatedUser) { Group.all({ transaction: t }).success(function(groups) {
expect(associatedUser).not.to.be.null groups[0].getUser({ transaction: t }).success(function(associatedUser) {
expect(associatedUser.id).to.equal(user.id) expect(associatedUser).not.to.be.null
expect(associatedUser.id).not.to.equal(fakeUser.id) expect(associatedUser.id).to.equal(user.id)
t.rollback().success(function() { done() }) expect(associatedUser.id).not.to.equal(fakeUser.id)
t.rollback().success(function() { done() })
})
}) })
}) })
}) })
...@@ -56,7 +58,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -56,7 +58,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
}) })
}) })
}) })
}) }
it('does not modify the passed arguments', function () { it('does not modify the passed arguments', function () {
var User = this.sequelize.define('user', {}) var User = this.sequelize.define('user', {})
...@@ -98,36 +100,38 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -98,36 +100,38 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
}) })
describe('setAssociation', function() { describe('setAssociation', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING }) var User = sequelize.define('User', { username: Support.Sequelize.STRING })
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING })
Group.hasOne(User) Group.hasOne(User)
sequelize.sync({ force: true }).success(function() { sequelize.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(user) { User.create({ username: 'foo' }).success(function(user) {
Group.create({ name: 'bar' }).success(function(group) { Group.create({ name: 'bar' }).success(function(group) {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
group group
.setUser(user, { transaction: t }) .setUser(user, { transaction: t })
.success(function() { .success(function() {
Group.all().success(function(groups) { Group.all().success(function(groups) {
groups[0].getUser().success(function(associatedUser) { groups[0].getUser().success(function(associatedUser) {
expect(associatedUser).to.be.null expect(associatedUser).to.be.null
t.rollback().success(function() { done() }) t.rollback().success(function() { done() })
})
}) })
}) })
}) .on('sql', function(sql, uuid) {
.on('sql', function(sql, uuid) { expect(uuid).to.not.equal('default')
expect(uuid).to.not.equal('default') })
}) })
}) })
}) })
}) })
}) })
}) })
}) }
it('can set an association with predefined primary keys', function(done) { it('can set an association with predefined primary keys', function(done) {
var User = this.sequelize.define('UserXYZZ', { userCoolIdTag: { type: Sequelize.INTEGER, primaryKey: true }, username: Sequelize.STRING }) var User = this.sequelize.define('UserXYZZ', { userCoolIdTag: { type: Sequelize.INTEGER, primaryKey: true }, username: Sequelize.STRING })
...@@ -227,24 +231,26 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -227,24 +231,26 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
}) })
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
, Group = sequelize.define('Group', { name: Sequelize.STRING }) var User = sequelize.define('User', { username: Sequelize.STRING })
, Group = sequelize.define('Group', { name: Sequelize.STRING })
User.hasOne(Group)
User.hasOne(Group)
sequelize.sync({ force: true }).success(function() {
User.create({ username: 'bob' }).success(function(user) { sequelize.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { User.create({ username: 'bob' }).success(function(user) {
user.createGroup({ name: 'testgroup' }, { transaction: t }).success(function() { sequelize.transaction().then(function(t) {
User.all().success(function (users) { user.createGroup({ name: 'testgroup' }, { transaction: t }).success(function() {
users[0].getGroup().success(function (group) { User.all().success(function (users) {
expect(group).to.be.null; users[0].getGroup().success(function (group) {
User.all({ transaction: t }).success(function (users) { expect(group).to.be.null;
users[0].getGroup({ transaction: t }).success(function (group) { User.all({ transaction: t }).success(function (users) {
expect(group).to.be.not.null; users[0].getGroup({ transaction: t }).success(function (group) {
t.rollback().success(function() { done() }) expect(group).to.be.not.null;
t.rollback().success(function() { done() })
})
}) })
}) })
}) })
...@@ -254,7 +260,8 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -254,7 +260,8 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
}) })
}) })
}) })
}) }
}) })
describe('foreign key', function () { describe('foreign key', function () {
......
...@@ -12,6 +12,8 @@ var chai = require('chai') ...@@ -12,6 +12,8 @@ var chai = require('chai')
, _ = require('lodash') , _ = require('lodash')
, moment = require('moment') , moment = require('moment')
, async = require('async') , async = require('async')
, current = Support.sequelize;
chai.use(datetime) chai.use(datetime)
chai.config.includeStack = true chai.config.includeStack = true
...@@ -700,22 +702,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -700,22 +702,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('find', function() { describe('find', function() {
it('supports the transaction option in the first parameter', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports the transaction option in the first parameter', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING, foo: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING, foo: Sequelize.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.create({ username: 'foo' }, { transaction: t }).success(function() { User.create({ username: 'foo' }, { transaction: t }).success(function() {
User.find({ where: { username: 'foo' }, transaction: t }).success(function(user) { User.find({ where: { username: 'foo' }, transaction: t }).success(function(user) {
expect(user).to.not.be.null expect(user).to.not.be.null
t.rollback().success(function() { done() }) t.rollback().success(function() { done() })
})
}) })
}) })
}) })
}) })
}) })
}) }
it('should not fail if model is paranoid and where is an empty array', function(done) { it('should not fail if model is paranoid and where is an empty array', function(done) {
var User = this.sequelize.define('User', { username: Sequelize.STRING }, { paranoid: true }) var User = this.sequelize.define('User', { username: Sequelize.STRING }, { paranoid: true })
...@@ -738,29 +742,32 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -738,29 +742,32 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('findOrInitialize', function() { describe('findOrInitialize', function() {
it('supports transactions', 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() { if (current.dialect.supports.transactions) {
sequelize.transaction().then(function(t) { it('supports transactions', function(done) {
User.create({ username: 'foo' }, { transaction: t }).success(function() { Support.prepareTransactionTest(this.sequelize, function(sequelize) {
User.findOrInitialize({ var User = sequelize.define('User', { username: Sequelize.STRING, foo: Sequelize.STRING })
where: {username: 'foo'}
}).spread(function(user1) { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) {
User.create({ username: 'foo' }, { transaction: t }).success(function() {
User.findOrInitialize({ User.findOrInitialize({
where: {username: 'foo'}, where: {username: 'foo'}
transaction: t }).spread(function(user1) {
}).spread(function(user2) {
User.findOrInitialize({ User.findOrInitialize({
where: {username: 'foo'}, where: {username: 'foo'},
defaults: { foo: 'asd' },
transaction: t transaction: t
}).spread(function(user3) { }).spread(function(user2) {
expect(user1.isNewRecord).to.be.true User.findOrInitialize({
expect(user2.isNewRecord).to.be.false where: {username: 'foo'},
expect(user3.isNewRecord).to.be.false defaults: { foo: 'asd' },
t.commit().success(function() { done() }) transaction: t
}).spread(function(user3) {
expect(user1.isNewRecord).to.be.true
expect(user2.isNewRecord).to.be.false
expect(user3.isNewRecord).to.be.false
t.commit().success(function() { done() })
})
}) })
}) })
}) })
...@@ -768,7 +775,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -768,7 +775,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
}) })
}) }
describe('returns an instance if it already exists', function() { describe('returns an instance if it already exists', function() {
it('with a single find field', function (done) { it('with a single find field', function (done) {
...@@ -828,19 +835,21 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -828,19 +835,21 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('update', function() { describe('update', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).done(function() { User.sync({ force: true }).done(function() {
User.create({ username: 'foo' }).done(function() { User.create({ username: 'foo' }).done(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.update({ username: 'bar' }, {where: {username: 'foo'}, transaction: t }).done(function(err) { User.update({ username: 'bar' }, {where: {username: 'foo'}, transaction: t }).done(function(err) {
User.all().done(function(err, users1) { User.all().done(function(err, users1) {
User.all({ transaction: t }).done(function(err, users2) { User.all({ transaction: t }).done(function(err, users2) {
expect(users1[0].username).to.equal('foo') expect(users1[0].username).to.equal('foo')
expect(users2[0].username).to.equal('bar') expect(users2[0].username).to.equal('bar')
t.rollback().success(function(){ done() }) t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
...@@ -848,7 +857,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -848,7 +857,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
}) })
}) }
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', {
...@@ -1046,19 +1055,21 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1046,19 +1055,21 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('destroy', function() { describe('destroy', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function() { User.create({ username: 'foo' }).success(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.destroy({transaction: t }).success(function() { User.destroy({transaction: t }).success(function() {
User.count().success(function(count1) { User.count().success(function(count1) {
User.count({ transaction: t }).success(function(count2) { User.count({ transaction: t }).success(function(count2) {
expect(count1).to.equal(1) expect(count1).to.equal(1)
expect(count2).to.equal(0) expect(count2).to.equal(0)
t.rollback().success(function(){ done() }) t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
...@@ -1066,7 +1077,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1066,7 +1077,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
}) })
}) }
it('deletes values that match filter', function(done) { it('deletes values that match filter', function(done) {
var self = this var self = this
...@@ -1469,25 +1480,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1469,25 +1480,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('count', function() { describe('count', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.create({ username: 'foo' }, { transaction: t }).success(function() { User.create({ username: 'foo' }, { transaction: t }).success(function() {
User.count().success(function(count1) { User.count().success(function(count1) {
User.count({ transaction: t }).success(function(count2) { User.count({ transaction: t }).success(function(count2) {
expect(count1).to.equal(0) expect(count1).to.equal(0)
expect(count2).to.equal(1) expect(count2).to.equal(1)
t.rollback().success(function(){ done() }) t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
}) })
}) })
}) })
}) }
it('counts all created objects', function(done) { it('counts all created objects', function(done) {
var self = this var self = this
...@@ -1569,25 +1582,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1569,25 +1582,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { age: Sequelize.INTEGER }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { age: Sequelize.INTEGER })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.bulkCreate([{ age: 2 }, { age: 5 }, { age: 3 }], { transaction: t }).success(function() { User.bulkCreate([{ age: 2 }, { age: 5 }, { age: 3 }], { transaction: t }).success(function() {
User.min('age').success(function(min1) { User.min('age').success(function(min1) {
User.min('age', { transaction: t }).success(function(min2) { User.min('age', { transaction: t }).success(function(min2) {
expect(min1).to.be.not.ok expect(min1).to.be.not.ok
expect(min2).to.equal(2) expect(min2).to.equal(2)
t.rollback().success(function(){ done() }) t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
}) })
}) })
}) })
}) }
it("should return the min value", function(done) { it("should return the min value", function(done) {
var self = this var self = this
...@@ -1658,25 +1673,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1658,25 +1673,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { age: Sequelize.INTEGER }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { age: Sequelize.INTEGER })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.bulkCreate([{ age: 2 }, { age: 5 }, { age: 3 }], { transaction: t }).success(function() { User.bulkCreate([{ age: 2 }, { age: 5 }, { age: 3 }], { transaction: t }).success(function() {
User.max('age').success(function(min1) { User.max('age').success(function(min1) {
User.max('age', { transaction: t }).success(function(min2) { User.max('age', { transaction: t }).success(function(min2) {
expect(min1).to.be.not.ok expect(min1).to.be.not.ok
expect(min2).to.equal(5) expect(min2).to.equal(5)
t.rollback().success(function(){ done() }) t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
}) })
}) })
}) })
}) }
it("should return the max value for a field named the same as an SQL reserved keyword", function(done) { it("should return the max value for a field named the same as an SQL reserved keyword", function(done) {
var self = this var self = this
...@@ -2203,25 +2220,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -2203,25 +2220,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
.then(function() { done() }) .then(function() { done() })
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.create({ username: 'foo' }, { transaction: t }).success(function() { User.create({ username: 'foo' }, { transaction: t }).success(function() {
User.where({ username: "foo" }).exec().success(function(users1) { User.where({ username: "foo" }).exec().success(function(users1) {
User.where({ username: "foo" }).exec({ transaction: t }).success(function(users2) { User.where({ username: "foo" }).exec({ transaction: t }).success(function(users2) {
expect(users1).to.have.length(0) expect(users1).to.have.length(0)
expect(users2).to.have.length(1) expect(users2).to.have.length(1)
t.rollback().success(function() { done() }) t.rollback().success(function() { done() })
})
}) })
}) })
}) })
}) })
}) })
}) })
}) }
it("selects all users with name 'foo'", function(done) { it("selects all users with name 'foo'", function(done) {
this this
...@@ -2463,7 +2482,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -2463,7 +2482,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
if (dialect !== 'sqlite') { if (dialect !== 'sqlite' && current.dialect.supports.transactions) {
it('supports multiple async transactions', function(done) { it('supports multiple async transactions', function(done) {
this.timeout(25000); this.timeout(25000);
Support.prepareTransactionTest(this.sequelize, function(sequelize) { Support.prepareTransactionTest(this.sequelize, function(sequelize) {
......
...@@ -10,6 +10,8 @@ var chai = require('chai') ...@@ -10,6 +10,8 @@ var chai = require('chai')
, datetime = require('chai-datetime') , datetime = require('chai-datetime')
, _ = require('lodash') , _ = require('lodash')
, assert = require('assert') , assert = require('assert')
, current = Support.sequelize;
chai.use(datetime) chai.use(datetime)
chai.config.includeStack = true chai.config.includeStack = true
...@@ -41,35 +43,37 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -41,35 +43,37 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}); });
describe('findOrCreate', function () { describe('findOrCreate', function () {
it("supports transactions", function(done) { if (current.dialect.supports.transactions) {
var self = this; it("supports transactions", function(done) {
this.sequelize.transaction().then(function(t) { var self = this;
self.User.findOrCreate({ where: { username: 'Username' }, defaults: { data: 'some data' }}, { transaction: t }).then(function() { this.sequelize.transaction().then(function(t) {
self.User.count().success(function(count) { self.User.findOrCreate({ where: { username: 'Username' }, defaults: { data: 'some data' }}, { transaction: t }).then(function() {
expect(count).to.equal(0) self.User.count().success(function(count) {
t.commit().success(function() { expect(count).to.equal(0)
self.User.count().success(function(count) { t.commit().success(function() {
expect(count).to.equal(1) self.User.count().success(function(count) {
done() expect(count).to.equal(1)
done()
})
}) })
}) })
}) })
}) })
}) })
})
it("supports more than one models per transaction", function(done) { it("supports more than one models per transaction", function(done) {
var self = this; var self = this;
this.sequelize.transaction().then(function(t) { this.sequelize.transaction().then(function(t) {
self.User.findOrCreate({ where: { username: 'Username'}, defaults: { data: 'some data' }}, { transaction: t }).then(function() { self.User.findOrCreate({ where: { username: 'Username'}, defaults: { data: 'some data' }}, { transaction: t }).then(function() {
self.Account.findOrCreate({ where: { accountName: 'accountName'}}, { transaction: t}).then(function(){ self.Account.findOrCreate({ where: { accountName: 'accountName'}}, { transaction: t}).then(function(){
t.commit().success(function() { t.commit().success(function() {
done() done()
})
}) })
}) })
}) })
}) })
}) }
it("returns instance if already existent. Single find field.", function(done) { it("returns instance if already existent. Single find field.", function(done) {
var self = this, var self = this,
...@@ -137,55 +141,59 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -137,55 +141,59 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it("should release transaction when meeting errors", function(){ if (current.dialect.supports.transactions) {
var self = this it("should release transaction when meeting errors", function(){
var self = this
var test = function(times) { var test = function(times) {
if (times > 10) { if (times > 10) {
return true; return true;
}
return self.Student.findOrCreate({
where: {
no: 1
} }
}) return self.Student.findOrCreate({
.timeout(1000) where: {
.catch(Promise.TimeoutError,function(e){ no: 1
throw new Error(e) }
}) })
.catch(Sequelize.ValidationError,function(err){ .timeout(1000)
return test(times+1); .catch(Promise.TimeoutError,function(e){
}) throw new Error(e)
} })
.catch(Sequelize.ValidationError,function(err){
return test(times+1);
})
}
return test(0); return test(0);
}) })
}
describe('several concurrent calls', function () { describe('several concurrent calls', function () {
it('works with a transaction', function () { if (current.dialect.supports.transactions) {
return this.sequelize.transaction().bind(this).then(function (transaction) { it('works with a transaction', function () {
return Promise.join( return this.sequelize.transaction().bind(this).then(function (transaction) {
this.User.findOrCreate({ where: { uniqueName: 'winner' }}, { transaction: transaction }), return Promise.join(
this.User.findOrCreate({ where: { uniqueName: 'winner' }}, { transaction: transaction }), this.User.findOrCreate({ where: { uniqueName: 'winner' }}, { transaction: transaction }),
function (first, second) { this.User.findOrCreate({ where: { uniqueName: 'winner' }}, { transaction: transaction }),
var firstInstance = first[0] function (first, second) {
, firstCreated = first[1] var firstInstance = first[0]
, secondInstance = second[0] , firstCreated = first[1]
, secondCreated = second[1]; , secondInstance = second[0]
, secondCreated = second[1];
// Depending on execution order and MAGIC either the first OR the second call should return true
expect(firstCreated ? !secondCreated : secondCreated).to.be.ok // XOR // Depending on execution order and MAGIC either the first OR the second call should return true
expect(firstCreated ? !secondCreated : secondCreated).to.be.ok // XOR
expect(firstInstance).to.be.ok;
expect(secondInstance).to.be.ok; expect(firstInstance).to.be.ok;
expect(secondInstance).to.be.ok;
expect(firstInstance.id).to.equal(secondInstance.id);
expect(firstInstance.id).to.equal(secondInstance.id);
return transaction.commit();
} return transaction.commit();
); }
);
});
}); });
}); }
// Creating two concurrent transactions and selecting / inserting from the same table throws sqlite off // Creating two concurrent transactions and selecting / inserting from the same table throws sqlite off
(dialect !== 'sqlite' ? it : it.skip)('works without a transaction', function () { (dialect !== 'sqlite' ? it : it.skip)('works without a transaction', function () {
...@@ -287,22 +295,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -287,22 +295,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}); });
}); });
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
var self = this; it('supports transactions', function(done) {
this.sequelize.transaction().then(function(t) { var self = this;
self.User.create({ username: 'user' }, { transaction: t }).success(function() { this.sequelize.transaction().then(function(t) {
self.User.count().success(function(count) { self.User.create({ username: 'user' }, { transaction: t }).success(function() {
expect(count).to.equal(0) self.User.count().success(function(count) {
t.commit().success(function() { expect(count).to.equal(0)
self.User.count().success(function(count) { t.commit().success(function() {
expect(count).to.equal(1) self.User.count().success(function(count) {
done() expect(count).to.equal(1)
done()
})
}) })
}) })
}) })
}) })
}) })
}) }
it('is possible to use casting when creating an instance', function (done) { it('is possible to use casting when creating an instance', function (done) {
var self = this var self = this
...@@ -960,22 +970,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -960,22 +970,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('bulkCreate', function() { describe('bulkCreate', function() {
it("supports transactions", function(done) { if (current.dialect.supports.transactions) {
var self = this; it("supports transactions", function(done) {
this.sequelize.transaction().then(function(t) { var self = this;
self.User this.sequelize.transaction().then(function(t) {
.bulkCreate([{ username: 'foo' }, { username: 'bar' }], { transaction: t }) self.User
.success(function() { .bulkCreate([{ username: 'foo' }, { username: 'bar' }], { transaction: t })
self.User.count().success(function(count1) { .success(function() {
self.User.count({ transaction: t }).success(function(count2) { self.User.count().success(function(count1) {
expect(count1).to.equal(0) self.User.count({ transaction: t }).success(function(count2) {
expect(count2).to.equal(2) expect(count1).to.equal(0)
t.rollback().success(function(){ done() }) expect(count2).to.equal(2)
t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
}) })
}) }
it('properly handles disparate field lists', function(done) { it('properly handles disparate field lists', function(done) {
var self = this var self = this
......
...@@ -11,6 +11,8 @@ var chai = require('chai') ...@@ -11,6 +11,8 @@ var chai = require('chai')
, promised = require("chai-as-promised") , promised = require("chai-as-promised")
, _ = require('lodash') , _ = require('lodash')
, async = require('async') , async = require('async')
, current = Support.sequelize;
chai.use(promised); chai.use(promised);
chai.use(datetime) chai.use(datetime)
...@@ -33,24 +35,26 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -33,24 +35,26 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('find', function() { describe('find', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { User.sync({ force: true }).success(function() {
User.create({ username: 'foo' }, { transaction: t }).success(function() { sequelize.transaction().then(function(t) {
User.find({ User.create({ username: 'foo' }, { transaction: t }).success(function() {
where: { username: 'foo' }
}).success(function(user1) {
User.find({ User.find({
where: { username: 'foo' }, where: { username: 'foo' }
}, { transaction: t }).success(function(user2) { }).success(function(user1) {
expect(user1).to.be.null User.find({
expect(user2).to.not.be.null where: { username: 'foo' },
}, { transaction: t }).success(function(user2) {
t.rollback().success(function() { expect(user1).to.be.null
done() expect(user2).to.not.be.null
t.rollback().success(function() {
done()
})
}) })
}) })
}) })
...@@ -58,7 +62,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -58,7 +62,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
}) })
}) }
describe('general / basic function', function() { describe('general / basic function', function() {
beforeEach(function(done) { beforeEach(function(done) {
......
...@@ -11,6 +11,8 @@ var chai = require('chai') ...@@ -11,6 +11,8 @@ var chai = require('chai')
, _ = require('lodash') , _ = require('lodash')
, moment = require('moment') , moment = require('moment')
, async = require('async') , async = require('async')
, current = Support.sequelize;
chai.use(datetime) chai.use(datetime)
chai.config.includeStack = true chai.config.includeStack = true
...@@ -33,22 +35,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -33,22 +35,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
describe('findAll', function() { describe('findAll', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { User.sync({ force: true }).success(function() {
User.create({ username: 'foo' }, { transaction: t }).success(function() { sequelize.transaction().then(function(t) {
User.findAll({ username: 'foo' }).success(function(users1) { User.create({ username: 'foo' }, { transaction: t }).success(function() {
User.findAll({ transaction: t }).success(function(users2) { User.findAll({ username: 'foo' }).success(function(users1) {
User.findAll({ username: 'foo' }, { transaction: t }).success(function(users3) { User.findAll({ transaction: t }).success(function(users2) {
expect(users1.length).to.equal(0) User.findAll({ username: 'foo' }, { transaction: t }).success(function(users3) {
expect(users2.length).to.equal(1) expect(users1.length).to.equal(0)
expect(users3.length).to.equal(1) expect(users2.length).to.equal(1)
expect(users3.length).to.equal(1)
t.rollback().success(function() {
done() t.rollback().success(function() {
done()
})
}) })
}) })
}) })
...@@ -57,7 +61,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -57,7 +61,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
}) })
}) }
describe('special where conditions/smartWhere object', function() { describe('special where conditions/smartWhere object', function() {
beforeEach(function(done) { beforeEach(function(done) {
...@@ -1364,26 +1368,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1364,26 +1368,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.create({ username: 'foo' }, { transaction: t }).success(function() { User.create({ username: 'foo' }, { transaction: t }).success(function() {
User.findAndCountAll().success(function(info1) { User.findAndCountAll().success(function(info1) {
User.findAndCountAll({ transaction: t }).success(function(info2) { User.findAndCountAll({ transaction: t }).success(function(info2) {
expect(info1.count).to.equal(0) expect(info1.count).to.equal(0)
expect(info2.count).to.equal(1) expect(info2.count).to.equal(1)
t.rollback().success(function(){ done() }) t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
}) })
}) })
}) })
}) }
it("handles where clause [only]", function(done) { it("handles where clause [only]", function(done) {
this.User.findAndCountAll({where: "id != " + this.users[0].id}).success(function(info) { this.User.findAndCountAll({where: "id != " + this.users[0].id}).success(function(info) {
...@@ -1503,25 +1509,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1503,25 +1509,27 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
User.create({ username: 'foo' }, { transaction: t }).success(function() { User.create({ username: 'foo' }, { transaction: t }).success(function() {
User.all().success(function(users1) { User.all().success(function(users1) {
User.all({ transaction: t }).success(function(users2) { User.all({ transaction: t }).success(function(users2) {
expect(users1.length).to.equal(0) expect(users1.length).to.equal(0)
expect(users2.length).to.equal(1) expect(users2.length).to.equal(1)
t.rollback().success(function(){ done() }) t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
}) })
}) })
}) })
}) }
it("should return all users", function(done) { it("should return all users", function(done) {
this.User.all().on('success', function(users) { this.User.all().on('success', function(users) {
......
...@@ -9,6 +9,8 @@ var chai = require('chai') ...@@ -9,6 +9,8 @@ var chai = require('chai')
, datetime = require('chai-datetime') , datetime = require('chai-datetime')
, uuid = require('node-uuid') , uuid = require('node-uuid')
, _ = require('lodash') , _ = require('lodash')
, current = Support.sequelize;
chai.use(datetime) chai.use(datetime)
chai.config.includeStack = true chai.config.includeStack = true
...@@ -272,19 +274,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -272,19 +274,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { number: Support.Sequelize.INTEGER }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { number: Support.Sequelize.INTEGER })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
User.create({ number: 1 }).success(function(user) { User.create({ number: 1 }).success(function(user) {
sequelize.transaction().then(function(t) { sequelize.transaction().then(function(t) {
user.increment('number', { by: 2, transaction: t }).success(function() { user.increment('number', { by: 2, transaction: t }).success(function() {
User.all().success(function(users1) { User.all().success(function(users1) {
User.all({ transaction: t }).success(function(users2) { User.all({ transaction: t }).success(function(users2) {
expect(users1[0].number).to.equal(1) expect(users1[0].number).to.equal(1)
expect(users2[0].number).to.equal(3) expect(users2[0].number).to.equal(3)
t.rollback().success(function() { done() }) t.rollback().success(function() { done() })
})
}) })
}) })
}) })
...@@ -292,7 +296,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -292,7 +296,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
}) })
}) }
it('supports where conditions', function(done) { it('supports where conditions', function(done) {
var self = this var self = this
...@@ -416,19 +420,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -416,19 +420,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
this.User.create({ id: 1, aNumber: 0, bNumber: 0 }).complete(done) this.User.create({ id: 1, aNumber: 0, bNumber: 0 }).complete(done)
}) })
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { number: Support.Sequelize.INTEGER }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { number: Support.Sequelize.INTEGER })
User.sync({ force: true }).success(function() {
User.create({ number: 3 }).success(function(user) { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { User.create({ number: 3 }).success(function(user) {
user.decrement('number', { by: 2, transaction: t }).success(function() { sequelize.transaction().then(function(t) {
User.all().success(function(users1) { user.decrement('number', { by: 2, transaction: t }).success(function() {
User.all({ transaction: t }).success(function(users2) { User.all().success(function(users1) {
expect(users1[0].number).to.equal(3) User.all({ transaction: t }).success(function(users2) {
expect(users2[0].number).to.equal(1) expect(users1[0].number).to.equal(3)
t.rollback().success(function() { done() }) expect(users2[0].number).to.equal(1)
t.rollback().success(function() { done() })
})
}) })
}) })
}) })
...@@ -436,7 +442,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -436,7 +442,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
}) })
}) }
it('with array', function(done) { it('with array', function(done) {
var self = this var self = this
...@@ -544,19 +550,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -544,19 +550,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
describe('reload', function () { describe('reload', function () {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING })
User.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(user) { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { User.create({ username: 'foo' }).success(function(user) {
User.update({ username: 'bar' }, {where: {username: 'foo'}, transaction: t }).success(function() { sequelize.transaction().then(function(t) {
user.reload().success(function(user) { User.update({ username: 'bar' }, {where: {username: 'foo'}, transaction: t }).success(function() {
expect(user.username).to.equal('foo') user.reload().success(function(user) {
user.reload({ transaction: t }).success(function(user) { expect(user.username).to.equal('foo')
expect(user.username).to.equal('bar') user.reload({ transaction: t }).success(function(user) {
t.rollback().success(function() { done() }) expect(user.username).to.equal('bar')
t.rollback().success(function() { done() })
})
}) })
}) })
}) })
...@@ -564,7 +572,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -564,7 +572,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
}) })
}) }
it("should return a reference to the same DAO instead of creating a new one", function(done) { it("should return a reference to the same DAO instead of creating a new one", function(done) {
this.User.create({ username: 'John Doe' }).complete(function(err, originalUser) { this.User.create({ username: 'John Doe' }).complete(function(err, originalUser) {
...@@ -748,25 +756,27 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -748,25 +756,27 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
describe('save', function() { describe('save', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING })
User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { User.sync({ force: true }).success(function() {
User.build({ username: 'foo' }).save({ transaction: t }).success(function() { sequelize.transaction().then(function(t) {
User.count().success(function(count1) { User.build({ username: 'foo' }).save({ transaction: t }).success(function() {
User.count({ transaction: t }).success(function(count2) { User.count().success(function(count1) {
expect(count1).to.equal(0) User.count({ transaction: t }).success(function(count2) {
expect(count2).to.equal(1) expect(count1).to.equal(0)
t.rollback().success(function(){ done() }) expect(count2).to.equal(1)
t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
}) })
}) })
}) })
}) }
it('only updates fields in passed array', function(done) { it('only updates fields in passed array', function(done) {
var self = this var self = this
...@@ -1600,19 +1610,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -1600,19 +1610,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
describe('updateAttributes', function() { describe('updateAttributes', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING })
User.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(user) { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { User.create({ username: 'foo' }).success(function(user) {
user.updateAttributes({ username: 'bar' }, { transaction: t }).success(function() { sequelize.transaction().then(function(t) {
User.all().success(function(users1) { user.updateAttributes({ username: 'bar' }, { transaction: t }).success(function() {
User.all({ transaction: t }).success(function(users2) { User.all().success(function(users1) {
expect(users1[0].username).to.equal('foo') User.all({ transaction: t }).success(function(users2) {
expect(users2[0].username).to.equal('bar') expect(users1[0].username).to.equal('foo')
t.rollback().success(function(){ done() }) expect(users2[0].username).to.equal('bar')
t.rollback().success(function(){ done() })
})
}) })
}) })
}) })
...@@ -1620,7 +1632,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -1620,7 +1632,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
}) })
}) }
it("updates attributes in the database", function(done) { it("updates attributes in the database", function(done) {
this.User.create({ username: 'user' }).success(function(user) { this.User.create({ username: 'user' }).success(function(user) {
...@@ -1734,19 +1746,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -1734,19 +1746,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
describe('destroy', function() { describe('destroy', function() {
it('supports transactions', function(done) { if (current.dialect.supports.transactions) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) { it('supports transactions', function(done) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING }) Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING })
User.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(user) { User.sync({ force: true }).success(function() {
sequelize.transaction().then(function(t) { User.create({ username: 'foo' }).success(function(user) {
user.destroy({ transaction: t }).success(function() { sequelize.transaction().then(function(t) {
User.count().success(function(count1) { user.destroy({ transaction: t }).success(function() {
User.count({ transaction: t }).success(function(count2) { User.count().success(function(count1) {
expect(count1).to.equal(1) User.count({ transaction: t }).success(function(count2) {
expect(count2).to.equal(0) expect(count1).to.equal(1)
t.rollback().success(function() { done() }) expect(count2).to.equal(0)
t.rollback().success(function() { done() })
})
}) })
}) })
}) })
...@@ -1754,7 +1768,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -1754,7 +1768,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
}) })
}) }
it('deletes a record from the database if dao is not paranoid', function(done) { it('deletes a record from the database if dao is not paranoid', function(done) {
var UserDestroy = this.sequelize.define('UserDestroy', { var UserDestroy = this.sequelize.define('UserDestroy', {
......
...@@ -11,6 +11,8 @@ var chai = require('chai') ...@@ -11,6 +11,8 @@ var chai = require('chai')
, Transaction = require(__dirname + '/../lib/transaction') , Transaction = require(__dirname + '/../lib/transaction')
, path = require('path') , path = require('path')
, sinon = require('sinon') , sinon = require('sinon')
, current = Support.sequelize;
chai.config.includeStack = true chai.config.includeStack = true
...@@ -866,61 +868,63 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -866,61 +868,63 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
}) })
}) })
describe('transaction', function() { if (current.dialect.supports.transactions) {
beforeEach(function(done) { describe('transaction', function() {
var self = this beforeEach(function(done) {
var self = this
Support.prepareTransactionTest(this.sequelize, function(sequelize) { Support.prepareTransactionTest(this.sequelize, function(sequelize) {
self.sequelizeWithTransaction = sequelize self.sequelizeWithTransaction = sequelize
done() done()
})
}) })
})
it('is a transaction method available', function() { it('is a transaction method available', function() {
expect(Support.Sequelize).to.respondTo('transaction') expect(Support.Sequelize).to.respondTo('transaction')
}) })
it('passes a transaction object to the callback', function(done) { it('passes a transaction object to the callback', function(done) {
this.sequelizeWithTransaction.transaction().then(function(t) { this.sequelizeWithTransaction.transaction().then(function(t) {
expect(t).to.be.instanceOf(Transaction) expect(t).to.be.instanceOf(Transaction)
done() done()
})
}) })
})
it('allows me to define a callback on the result', function(done) { it('allows me to define a callback on the result', function(done) {
this this
.sequelizeWithTransaction .sequelizeWithTransaction
.transaction().then(function(t) { t.commit() }) .transaction().then(function(t) { t.commit() })
.done(done) .done(done)
}) })
if (dialect === 'sqlite') { if (dialect === 'sqlite') {
it("correctly scopes transaction from other connections", function(done) { it("correctly scopes transaction from other connections", function(done) {
var TransactionTest = this.sequelizeWithTransaction.define('TransactionTest', { name: DataTypes.STRING }, { timestamps: false }) var TransactionTest = this.sequelizeWithTransaction.define('TransactionTest', { name: DataTypes.STRING }, { timestamps: false })
, self = this , self = this
var count = function(transaction, callback) { var count = function(transaction, callback) {
var sql = self.sequelizeWithTransaction.getQueryInterface().QueryGenerator.selectQuery('TransactionTests', { attributes: [['count(*)', 'cnt']] }) var sql = self.sequelizeWithTransaction.getQueryInterface().QueryGenerator.selectQuery('TransactionTests', { attributes: [['count(*)', 'cnt']] })
self self
.sequelizeWithTransaction .sequelizeWithTransaction
.query(sql, null, { plain: true, raw: true, transaction: transaction }) .query(sql, null, { plain: true, raw: true, transaction: transaction })
.success(function(result) { callback(result.cnt) }) .success(function(result) { callback(result.cnt) })
} }
TransactionTest.sync({ force: true }).success(function() { TransactionTest.sync({ force: true }).success(function() {
self.sequelizeWithTransaction.transaction().then(function(t1) { self.sequelizeWithTransaction.transaction().then(function(t1) {
self.sequelizeWithTransaction.query('INSERT INTO ' + qq('TransactionTests') + ' (' + qq('name') + ') VALUES (\'foo\');', null, { plain: true, raw: true, transaction: t1 }).success(function() { self.sequelizeWithTransaction.query('INSERT INTO ' + qq('TransactionTests') + ' (' + qq('name') + ') VALUES (\'foo\');', null, { plain: true, raw: true, transaction: t1 }).success(function() {
count(null, function(cnt) { count(null, function(cnt) {
expect(cnt).to.equal(0) expect(cnt).to.equal(0)
count(t1, function(cnt) { count(t1, function(cnt) {
expect(cnt).to.equal(1) expect(cnt).to.equal(1)
t1.commit().success(function() { t1.commit().success(function() {
count(null, function(cnt) { count(null, function(cnt) {
expect(cnt).to.equal(1) expect(cnt).to.equal(1)
done() done()
})
}) })
}) })
}) })
...@@ -928,43 +932,43 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -928,43 +932,43 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
}) })
}) })
}) })
}) } else {
} else { it("correctly handles multiple transactions", function(done) {
it("correctly handles multiple transactions", function(done) { var TransactionTest = this.sequelizeWithTransaction.define('TransactionTest', { name: DataTypes.STRING }, { timestamps: false })
var TransactionTest = this.sequelizeWithTransaction.define('TransactionTest', { name: DataTypes.STRING }, { timestamps: false }) , self = this
, self = this
var count = function(transaction, callback) {
var count = function(transaction, callback) { var sql = self.sequelizeWithTransaction.getQueryInterface().QueryGenerator.selectQuery('TransactionTests', { attributes: [['count(*)', 'cnt']] })
var sql = self.sequelizeWithTransaction.getQueryInterface().QueryGenerator.selectQuery('TransactionTests', { attributes: [['count(*)', 'cnt']] })
self
self .sequelizeWithTransaction
.sequelizeWithTransaction .query(sql, null, { plain: true, raw: true, transaction: transaction })
.query(sql, null, { plain: true, raw: true, transaction: transaction }) .success(function(result) { callback(parseInt(result.cnt, 10)) })
.success(function(result) { callback(parseInt(result.cnt, 10)) }) }
}
TransactionTest.sync({ force: true }).success(function() {
self.sequelizeWithTransaction.transaction().then(function(t1) {
self.sequelizeWithTransaction.query('INSERT INTO ' + qq('TransactionTests') + ' (' + qq('name') + ') VALUES (\'foo\');', null, { plain: true, raw: true, transaction: t1 }).success(function() {
self.sequelizeWithTransaction.transaction().then(function(t2) {
self.sequelizeWithTransaction.query('INSERT INTO ' + qq('TransactionTests') + ' (' + qq('name') + ') VALUES (\'bar\');', null, { plain: true, raw: true, transaction: t2 }).success(function() {
count(null, function(cnt) {
expect(cnt).to.equal(0)
count(t1, function(cnt) { TransactionTest.sync({ force: true }).success(function() {
expect(cnt).to.equal(1) self.sequelizeWithTransaction.transaction().then(function(t1) {
self.sequelizeWithTransaction.query('INSERT INTO ' + qq('TransactionTests') + ' (' + qq('name') + ') VALUES (\'foo\');', null, { plain: true, raw: true, transaction: t1 }).success(function() {
self.sequelizeWithTransaction.transaction().then(function(t2) {
self.sequelizeWithTransaction.query('INSERT INTO ' + qq('TransactionTests') + ' (' + qq('name') + ') VALUES (\'bar\');', null, { plain: true, raw: true, transaction: t2 }).success(function() {
count(null, function(cnt) {
expect(cnt).to.equal(0)
count(t2, function(cnt) { count(t1, function(cnt) {
expect(cnt).to.equal(1) expect(cnt).to.equal(1)
t2.rollback().success(function() { count(t2, function(cnt) {
count(t2, function(cnt) { expect(cnt).to.equal(1)
expect(cnt).to.equal(0)
t2.rollback().success(function() {
count(t2, function(cnt) {
expect(cnt).to.equal(0)
t1.commit().success(function() { t1.commit().success(function() {
count(null, function(cnt) { count(null, function(cnt) {
expect(cnt).to.equal(1) expect(cnt).to.equal(1)
done(); done();
})
}) })
}) })
}) })
...@@ -977,25 +981,25 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -977,25 +981,25 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
}) })
}) })
}) })
}) }
}
it('supports nested transactions using savepoints', function(done) { it('supports nested transactions using savepoints', function(done) {
var self = this var self = this
var User = this.sequelizeWithTransaction.define('Users', { username: DataTypes.STRING }) var User = this.sequelizeWithTransaction.define('Users', { username: DataTypes.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
self.sequelizeWithTransaction.transaction().then(function(t1) { self.sequelizeWithTransaction.transaction().then(function(t1) {
User.create({ username: 'foo' }, { transaction: t1 }).success(function(user) { User.create({ username: 'foo' }, { transaction: t1 }).success(function(user) {
self.sequelizeWithTransaction.transaction({ transaction: t1 }).then(function(t2) { self.sequelizeWithTransaction.transaction({ transaction: t1 }).then(function(t2) {
user.updateAttributes({ username: 'bar' }, { transaction: t2 }).success(function() { user.updateAttributes({ username: 'bar' }, { transaction: t2 }).success(function() {
t2.commit().then(function() { t2.commit().then(function() {
user.reload({ transaction: t1 }).success(function(newUser) { user.reload({ transaction: t1 }).success(function(newUser) {
expect(newUser.username).to.equal('bar') expect(newUser.username).to.equal('bar')
t1.commit().then(function() { t1.commit().then(function() {
done() done()
}); });
})
}) })
}) })
}) })
...@@ -1003,87 +1007,87 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -1003,87 +1007,87 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
}) })
}) })
}) })
})
describe('supports rolling back to savepoints', function () { describe('supports rolling back to savepoints', function () {
beforeEach(function () { beforeEach(function () {
this.User = this.sequelizeWithTransaction.define('user', {}); this.User = this.sequelizeWithTransaction.define('user', {});
return this.sequelizeWithTransaction.sync({ force: true }); return this.sequelizeWithTransaction.sync({ force: true });
}) })
it('rolls back to the first savepoint, undoing everything', function () { it('rolls back to the first savepoint, undoing everything', function () {
return this.sequelizeWithTransaction.transaction().bind(this).then(function(transaction) { return this.sequelizeWithTransaction.transaction().bind(this).then(function(transaction) {
this.transaction = transaction; this.transaction = transaction;
return this.sequelizeWithTransaction.transaction({ transaction: transaction }); return this.sequelizeWithTransaction.transaction({ transaction: transaction });
}).then(function (sp1) { }).then(function (sp1) {
this.sp1 = sp1; this.sp1 = sp1;
return this.User.create({}, { transaction: this.transaction }); return this.User.create({}, { transaction: this.transaction });
}).then(function () { }).then(function () {
return this.sequelizeWithTransaction.transaction({ transaction: this.transaction }); return this.sequelizeWithTransaction.transaction({ transaction: this.transaction });
}).then(function (sp2) { }).then(function (sp2) {
this.sp2 = sp2; this.sp2 = sp2;
return this.User.create({}, { transaction: this.transaction }); return this.User.create({}, { transaction: this.transaction });
}).then(function () { }).then(function () {
return this.User.findAll({}, { transaction: this.transaction }); return this.User.findAll({}, { transaction: this.transaction });
}).then(function (users) { }).then(function (users) {
expect(users).to.have.length(2); expect(users).to.have.length(2);
return this.sp1.rollback(); return this.sp1.rollback();
}).then(function () { }).then(function () {
return this.User.findAll({}, { transaction: this.transaction }); return this.User.findAll({}, { transaction: this.transaction });
}).then(function (users) { }).then(function (users) {
expect(users).to.have.length(0); expect(users).to.have.length(0);
return this.transaction.rollback(); return this.transaction.rollback();
});
}); });
});
it('rolls back to the most recent savepoint, only undoing recent changes', function () { it('rolls back to the most recent savepoint, only undoing recent changes', function () {
return this.sequelizeWithTransaction.transaction().bind(this).then(function(transaction) { return this.sequelizeWithTransaction.transaction().bind(this).then(function(transaction) {
this.transaction = transaction; this.transaction = transaction;
return this.sequelizeWithTransaction.transaction({ transaction: transaction }); return this.sequelizeWithTransaction.transaction({ transaction: transaction });
}).then(function (sp1) { }).then(function (sp1) {
this.sp1 = sp1; this.sp1 = sp1;
return this.User.create({}, { transaction: this.transaction }); return this.User.create({}, { transaction: this.transaction });
}).then(function () { }).then(function () {
return this.sequelizeWithTransaction.transaction({ transaction: this.transaction }); return this.sequelizeWithTransaction.transaction({ transaction: this.transaction });
}).then(function (sp2) { }).then(function (sp2) {
this.sp2 = sp2; this.sp2 = sp2;
return this.User.create({}, { transaction: this.transaction }); return this.User.create({}, { transaction: this.transaction });
}).then(function () { }).then(function () {
return this.User.findAll({}, { transaction: this.transaction }); return this.User.findAll({}, { transaction: this.transaction });
}).then(function (users) { }).then(function (users) {
expect(users).to.have.length(2); expect(users).to.have.length(2);
return this.sp2.rollback(); return this.sp2.rollback();
}).then(function () { }).then(function () {
return this.User.findAll({}, { transaction: this.transaction }); return this.User.findAll({}, { transaction: this.transaction });
}).then(function (users) { }).then(function (users) {
expect(users).to.have.length(1); expect(users).to.have.length(1);
return this.transaction.rollback(); return this.transaction.rollback();
});
}); });
}); });
});
it('supports rolling back a nested transaction', function(done) { it('supports rolling back a nested transaction', function(done) {
var self = this var self = this
var User = this.sequelizeWithTransaction.define('Users', { username: DataTypes.STRING }) var User = this.sequelizeWithTransaction.define('Users', { username: DataTypes.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
self.sequelizeWithTransaction.transaction().then(function(t1) { self.sequelizeWithTransaction.transaction().then(function(t1) {
User.create({ username: 'foo' }, { transaction: t1 }).success(function(user) { User.create({ username: 'foo' }, { transaction: t1 }).success(function(user) {
self.sequelizeWithTransaction.transaction({ transaction: t1 }).then(function(t2) { self.sequelizeWithTransaction.transaction({ transaction: t1 }).then(function(t2) {
user.updateAttributes({ username: 'bar' }, { transaction: t2 }).success(function() { user.updateAttributes({ username: 'bar' }, { transaction: t2 }).success(function() {
t2.rollback().then(function() { t2.rollback().then(function() {
user.reload({ transaction: t2 }).success(function(newUser) { user.reload({ transaction: t2 }).success(function(newUser) {
expect(newUser.username).to.equal('foo') expect(newUser.username).to.equal('foo')
t1.commit().then(function() { t1.commit().then(function() {
done() done()
}); });
})
}) })
}) })
}) })
...@@ -1091,21 +1095,21 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -1091,21 +1095,21 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
}) })
}) })
}) })
})
it('supports rolling back outermost transaction', function(done) { it('supports rolling back outermost transaction', function(done) {
var self = this var self = this
var User = this.sequelizeWithTransaction.define('Users', { username: DataTypes.STRING }) var User = this.sequelizeWithTransaction.define('Users', { username: DataTypes.STRING })
User.sync({ force: true }).success(function() { User.sync({ force: true }).success(function() {
self.sequelizeWithTransaction.transaction().then(function(t1) { self.sequelizeWithTransaction.transaction().then(function(t1) {
User.create({ username: 'foo' }, { transaction: t1 }).success(function(user) { User.create({ username: 'foo' }, { transaction: t1 }).success(function(user) {
self.sequelizeWithTransaction.transaction({ transaction: t1 }).then(function(t2) { self.sequelizeWithTransaction.transaction({ transaction: t1 }).then(function(t2) {
user.updateAttributes({ username: 'bar' }, { transaction: t2 }).success(function() { user.updateAttributes({ username: 'bar' }, { transaction: t2 }).success(function() {
t1.rollback().then(function() { t1.rollback().then(function() {
User.findAll().success(function(users) { User.findAll().success(function(users) {
expect(users.length).to.equal(0); expect(users.length).to.equal(0);
done() done()
})
}) })
}) })
}) })
...@@ -1114,6 +1118,6 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -1114,6 +1118,6 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
}) })
}) })
}) })
}) }
}) })
}) })
...@@ -3,6 +3,10 @@ var chai = require('chai') ...@@ -3,6 +3,10 @@ var chai = require('chai')
, Support = require(__dirname + '/support') , Support = require(__dirname + '/support')
, Promise = require(__dirname + '/../lib/promise') , Promise = require(__dirname + '/../lib/promise')
, Transaction = require(__dirname + '/../lib/transaction') , Transaction = require(__dirname + '/../lib/transaction')
, current = Support.sequelize;
if (current.dialect.supports.transactions) {
describe(Support.getTestDialectTeaser("Sequelize#transaction"), function () { describe(Support.getTestDialectTeaser("Sequelize#transaction"), function () {
this.timeout(4000); this.timeout(4000);
...@@ -182,3 +186,5 @@ describe(Support.getTestDialectTeaser("Sequelize#transaction"), function () { ...@@ -182,3 +186,5 @@ describe(Support.getTestDialectTeaser("Sequelize#transaction"), function () {
}) })
}) })
}) })
}
...@@ -4,7 +4,6 @@ var chai = require('chai') ...@@ -4,7 +4,6 @@ var chai = require('chai')
, expect = chai.expect , expect = chai.expect
, Support = require(__dirname + '/support') , Support = require(__dirname + '/support')
, dialect = Support.getTestDialect() , dialect = Support.getTestDialect()
, Transaction = require(__dirname + '/../lib/transaction')
, Sequelize = require(__dirname + '/../index') , Sequelize = require(__dirname + '/../index')
, Promise = Sequelize.Promise , Promise = Sequelize.Promise
, sinon = require('sinon'); , sinon = require('sinon');
......
...@@ -7,6 +7,8 @@ var chai = require('chai') ...@@ -7,6 +7,8 @@ var chai = require('chai')
, sinon = require('sinon') , sinon = require('sinon')
, current = Support.sequelize; , current = Support.sequelize;
if (current.dialect.supports.transactions) {
describe(Support.getTestDialectTeaser("Transaction"), function () { describe(Support.getTestDialectTeaser("Transaction"), function () {
this.timeout(4000); this.timeout(4000);
describe('constructor', function() { describe('constructor', function() {
...@@ -173,3 +175,5 @@ describe(Support.getTestDialectTeaser("Transaction"), function () { ...@@ -173,3 +175,5 @@ describe(Support.getTestDialectTeaser("Transaction"), function () {
}); });
} }
}); });
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!