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

Commit a1ec8a18 by Andy Edwards Committed by GitHub

test: replace Promise.join calls with Promise.all (#12134)

1 parent 39a1f11f
...@@ -35,23 +35,19 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => { ...@@ -35,23 +35,19 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => {
Task.User = Task.belongsTo(User, { as: 'user' }); Task.User = Task.belongsTo(User, { as: 'user' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([Task.create({
Task.create({
id: 1, id: 1,
user: { id: 1 } user: { id: 1 }
}, { }, {
include: [Task.User] include: [Task.User]
}), }), Task.create({
Task.create({
id: 2, id: 2,
user: { id: 2 } user: { id: 2 }
}, { }, {
include: [Task.User] include: [Task.User]
}), }), Task.create({
Task.create({
id: 3 id: 3
}) })]);
);
}).then(tasks => { }).then(tasks => {
return Task.User.get(tasks).then(result => { return Task.User.get(tasks).then(result => {
expect(result[tasks[0].id].id).to.equal(tasks[0].user.id); expect(result[tasks[0].id].id).to.equal(tasks[0].user.id);
...@@ -366,10 +362,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => { ...@@ -366,10 +362,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => {
Comment.belongsTo(Post, { foreignKey: 'post_id' }); Comment.belongsTo(Post, { foreignKey: 'post_id' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([Post.create(), Comment.create()]).then(async ([post, comment]) => {
Post.create(),
Comment.create()
).then(async ([post, comment]) => {
expect(comment.get('post_id')).not.to.be.ok; expect(comment.get('post_id')).not.to.be.ok;
const setter = await comment.setPost(post, { save: false }); const setter = await comment.setPost(post, { save: false });
...@@ -1029,9 +1022,10 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => { ...@@ -1029,9 +1022,10 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => {
it('should load with an alias', function() { it('should load with an alias', function() {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.Individual.create({ name: 'Foo Bar' }), this.Individual.create({ name: 'Foo Bar' }),
this.Hat.create({ name: 'Baz' })); this.Hat.create({ name: 'Baz' })
]);
}).then(([individual, hat]) => { }).then(([individual, hat]) => {
return individual.setPersonwearinghat(hat); return individual.setPersonwearinghat(hat);
}).then(() => { }).then(() => {
...@@ -1058,9 +1052,10 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => { ...@@ -1058,9 +1052,10 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => {
it('should load all', function() { it('should load all', function() {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.Individual.create({ name: 'Foo Bar' }), this.Individual.create({ name: 'Foo Bar' }),
this.Hat.create({ name: 'Baz' })); this.Hat.create({ name: 'Baz' })
]);
}).then(([individual, hat]) => { }).then(([individual, hat]) => {
return individual.setPersonwearinghat(hat); return individual.setPersonwearinghat(hat);
}).then(() => { }).then(() => {
......
...@@ -45,10 +45,10 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -45,10 +45,10 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
include: [Task] include: [Task]
}); });
}).then(user => { }).then(user => {
return Promise.join( return Promise.all([
user.get('Tasks')[0].createSubtask({ title: 'Make a startup', active: false }), user.get('Tasks')[0].createSubtask({ title: 'Make a startup', active: false }),
user.get('Tasks')[0].createSubtask({ title: 'Engage rock stars', active: true }) user.get('Tasks')[0].createSubtask({ title: 'Engage rock stars', active: true })
).then(() => user); ]).then(() => user);
}).then(user => { }).then(user => {
return expect(user.countTasks({ return expect(user.countTasks({
attributes: [Task.primaryKeyField, 'title'], attributes: [Task.primaryKeyField, 'title'],
...@@ -75,8 +75,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -75,8 +75,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
User.Tasks = User.hasMany(Task, { as: 'tasks' }); User.Tasks = User.hasMany(Task, { as: 'tasks' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
id: 1, id: 1,
tasks: [ tasks: [
{}, {},
...@@ -85,19 +84,16 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -85,19 +84,16 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}), }), User.create({
User.create({
id: 2, id: 2,
tasks: [ tasks: [
{} {}
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}), }), User.create({
User.create({
id: 3 id: 3
}) })]);
);
}).then(users => { }).then(users => {
return User.Tasks.get(users).then(result => { return User.Tasks.get(users).then(result => {
expect(result[users[0].id].length).to.equal(3); expect(result[users[0].id].length).to.equal(3);
...@@ -116,8 +112,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -116,8 +112,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
User.Tasks = User.hasMany(Task, { as: 'tasks' }); User.Tasks = User.hasMany(Task, { as: 'tasks' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
tasks: [ tasks: [
{ title: 'b' }, { title: 'b' },
{ title: 'd' }, { title: 'd' },
...@@ -126,8 +121,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -126,8 +121,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}), }), User.create({
User.create({
tasks: [ tasks: [
{ title: 'a' }, { title: 'a' },
{ title: 'c' }, { title: 'c' },
...@@ -135,8 +129,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -135,8 +129,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}) })]);
);
}).then(users => { }).then(users => {
return User.Tasks.get(users, { return User.Tasks.get(users, {
limit: 2, limit: 2,
...@@ -168,8 +161,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -168,8 +161,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
Task.SubTasks = Task.hasMany(SubTask, { as: 'subtasks' }); Task.SubTasks = Task.hasMany(SubTask, { as: 'subtasks' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
id: 1, id: 1,
tasks: [ tasks: [
{ title: 'b', subtasks: [ { title: 'b', subtasks: [
...@@ -190,8 +182,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -190,8 +182,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [{ association: User.Tasks, include: [Task.SubTasks] }] include: [{ association: User.Tasks, include: [Task.SubTasks] }]
}), }), User.create({
User.create({
id: 2, id: 2,
tasks: [ tasks: [
{ title: 'a', subtasks: [ { title: 'a', subtasks: [
...@@ -209,8 +200,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -209,8 +200,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [{ association: User.Tasks, include: [Task.SubTasks] }] include: [{ association: User.Tasks, include: [Task.SubTasks] }]
}) })]);
);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [{ include: [{
...@@ -275,8 +265,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -275,8 +265,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
Task.Category = Task.belongsTo(Category, { as: 'category', foreignKey: 'categoryId' }); Task.Category = Task.belongsTo(Category, { as: 'category', foreignKey: 'categoryId' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
tasks: [ tasks: [
{ title: 'b', category: {} }, { title: 'b', category: {} },
{ title: 'd', category: {} }, { title: 'd', category: {} },
...@@ -285,8 +274,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -285,8 +274,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [{ association: User.Tasks, include: [Task.Category] }] include: [{ association: User.Tasks, include: [Task.Category] }]
}), }), User.create({
User.create({
tasks: [ tasks: [
{ title: 'a', category: {} }, { title: 'a', category: {} },
{ title: 'c', category: {} }, { title: 'c', category: {} },
...@@ -294,8 +282,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -294,8 +282,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [{ association: User.Tasks, include: [Task.Category] }] include: [{ association: User.Tasks, include: [Task.Category] }]
}) })]);
);
}).then(users => { }).then(users => {
return User.Tasks.get(users, { return User.Tasks.get(users, {
limit: 2, limit: 2,
...@@ -340,8 +327,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -340,8 +327,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
}).then(() => { }).then(() => {
return SubTask.sync({ force: true }); return SubTask.sync({ force: true });
}).then(() => { }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
id: 1, id: 1,
tasks: [ tasks: [
{ title: 'b', subtasks: [ { title: 'b', subtasks: [
...@@ -362,8 +348,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -362,8 +348,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [{ association: User.Tasks, include: [Task.SubTasks] }] include: [{ association: User.Tasks, include: [Task.SubTasks] }]
}), }), User.create({
User.create({
id: 2, id: 2,
tasks: [ tasks: [
{ title: 'a', subtasks: [ { title: 'a', subtasks: [
...@@ -381,8 +366,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -381,8 +366,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
] ]
}, { }, {
include: [{ association: User.Tasks, include: [Task.SubTasks] }] include: [{ association: User.Tasks, include: [Task.SubTasks] }]
}) })]);
);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [{ include: [{
...@@ -1719,9 +1703,10 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -1719,9 +1703,10 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
it('should load with an alias', function() { it('should load with an alias', function() {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.Individual.create({ name: 'Foo Bar' }), this.Individual.create({ name: 'Foo Bar' }),
this.Hat.create({ name: 'Baz' })); this.Hat.create({ name: 'Baz' })
]);
}).then(([individual, hat]) => { }).then(([individual, hat]) => {
return individual.addPersonwearinghat(hat); return individual.addPersonwearinghat(hat);
}).then(() => { }).then(() => {
...@@ -1738,9 +1723,10 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { ...@@ -1738,9 +1723,10 @@ describe(Support.getTestDialectTeaser('HasMany'), () => {
it('should load all', function() { it('should load all', function() {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.Individual.create({ name: 'Foo Bar' }), this.Individual.create({ name: 'Foo Bar' }),
this.Hat.create({ name: 'Baz' })); this.Hat.create({ name: 'Baz' })
]);
}).then(([individual, hat]) => { }).then(([individual, hat]) => {
return individual.addPersonwearinghat(hat); return individual.addPersonwearinghat(hat);
}).then(() => { }).then(() => {
......
...@@ -33,23 +33,19 @@ describe(Support.getTestDialectTeaser('HasOne'), () => { ...@@ -33,23 +33,19 @@ describe(Support.getTestDialectTeaser('HasOne'), () => {
Player.User = Player.hasOne(User, { as: 'user' }); Player.User = Player.hasOne(User, { as: 'user' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([Player.create({
Player.create({
id: 1, id: 1,
user: {} user: {}
}, { }, {
include: [Player.User] include: [Player.User]
}), }), Player.create({
Player.create({
id: 2, id: 2,
user: {} user: {}
}, { }, {
include: [Player.User] include: [Player.User]
}), }), Player.create({
Player.create({
id: 3 id: 3
}) })]);
);
}).then(players => { }).then(players => {
return Player.User.get(players).then(result => { return Player.User.get(players).then(result => {
expect(result[players[0].id].id).to.equal(players[0].user.id); expect(result[players[0].id].id).to.equal(players[0].user.id);
...@@ -900,9 +896,10 @@ describe(Support.getTestDialectTeaser('HasOne'), () => { ...@@ -900,9 +896,10 @@ describe(Support.getTestDialectTeaser('HasOne'), () => {
it('should load with an alias', function() { it('should load with an alias', function() {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.Individual.create({ name: 'Foo Bar' }), this.Individual.create({ name: 'Foo Bar' }),
this.Hat.create({ name: 'Baz' })); this.Hat.create({ name: 'Baz' })
]);
}).then(([individual, hat]) => { }).then(([individual, hat]) => {
return individual.setPersonwearinghat(hat); return individual.setPersonwearinghat(hat);
}).then(() => { }).then(() => {
...@@ -929,9 +926,10 @@ describe(Support.getTestDialectTeaser('HasOne'), () => { ...@@ -929,9 +926,10 @@ describe(Support.getTestDialectTeaser('HasOne'), () => {
it('should load all', function() { it('should load all', function() {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.Individual.create({ name: 'Foo Bar' }), this.Individual.create({ name: 'Foo Bar' }),
this.Hat.create({ name: 'Baz' })); this.Hat.create({ name: 'Baz' })
]);
}).then(([individual, hat]) => { }).then(([individual, hat]) => {
return individual.setPersonwearinghat(hat); return individual.setPersonwearinghat(hat);
}).then(() => { }).then(() => {
......
...@@ -168,10 +168,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -168,10 +168,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}; };
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([Person.create(), Company.create()]).then(([person, company]) => {
Person.create(),
Company.create()
).then(([person, company]) => {
return person.setEmployer(company); return person.setEmployer(company);
}); });
}).then(() => { }).then(() => {
...@@ -214,14 +211,11 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -214,14 +211,11 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return User.create().then(user => { return User.create().then(user => {
return Promise.join( return Promise.all([user.createTask({
user.createTask({
title: 'trivial' title: 'trivial'
}), }), user.createTask({
user.createTask({
title: 'pursuit' title: 'pursuit'
}) })]);
);
}).then(() => { }).then(() => {
return User.findOne({ return User.findOne({
include: [ include: [
...@@ -271,10 +265,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -271,10 +265,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
user: User.create(), user: User.create(),
group: Group.create() group: Group.create()
}).then(props => { }).then(props => {
return Promise.join( return Promise.all([props.task.setUser(props.user), props.user.setGroup(props.group)]).then(() => props);
props.task.setUser(props.user),
props.user.setGroup(props.group)
).then(() => props);
}).then(props => { }).then(props => {
return Task.findOne({ return Task.findOne({
where: { where: {
......
...@@ -250,28 +250,20 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -250,28 +250,20 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Tag.belongsToMany(Product, { through: ProductTag }); Tag.belongsToMany(Product, { through: ProductTag });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([Set.bulkCreate([
Set.bulkCreate([
{ title: 'office' } { title: 'office' }
]), ]), Product.bulkCreate([
Product.bulkCreate([
{ title: 'Chair' }, { title: 'Chair' },
{ title: 'Desk' }, { title: 'Desk' },
{ title: 'Dress' } { title: 'Dress' }
]), ]), Tag.bulkCreate([
Tag.bulkCreate([
{ name: 'A' }, { name: 'A' },
{ name: 'B' }, { name: 'B' },
{ name: 'C' } { name: 'C' }
]) ])]).then(() => {
).then(() => { return Promise.all([Set.findAll(), Product.findAll(), Tag.findAll()]);
return Promise.join(
Set.findAll(),
Product.findAll(),
Tag.findAll()
);
}).then(([sets, products, tags]) => { }).then(([sets, products, tags]) => {
return Promise.join( return Promise.all([
sets[0].addProducts([products[0], products[1]]), sets[0].addProducts([products[0], products[1]]),
products[0].addTag(tags[0], { priority: 1 }).then(() => { products[0].addTag(tags[0], { priority: 1 }).then(() => {
return products[0].addTag(tags[1], { priority: 2 }); return products[0].addTag(tags[1], { priority: 2 });
...@@ -283,7 +275,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -283,7 +275,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}).then(() => { }).then(() => {
return products[2].addTag(tags[2], { priority: 0 }); return products[2].addTag(tags[2], { priority: 0 });
}) })
); ]);
}).then(() => { }).then(() => {
return Set.findAll({ return Set.findAll({
include: [{ include: [{
...@@ -453,8 +445,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -453,8 +445,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
G.belongsTo(H); G.belongsTo(H);
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([A.bulkCreate([
A.bulkCreate([
{}, {},
{}, {},
{}, {},
...@@ -465,8 +456,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -465,8 +456,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{} {}
]).then(() => { ]).then(() => {
return A.findAll(); return A.findAll();
}), }), (function(singles) {
(function(singles) {
let promise = Promise.resolve(), let promise = Promise.resolve(),
previousInstance, previousInstance,
b; b;
...@@ -489,8 +479,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -489,8 +479,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}); });
return promise; return promise;
})([B, C, D, E, F, G, H]) })([B, C, D, E, F, G, H])]).then(([as, b]) => {
).then(([as, b]) => {
return Promise.all(as.map(a => { return Promise.all(as.map(a => {
return a.setB(b); return a.setB(b);
})); }));
...@@ -545,8 +534,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -545,8 +534,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
G.belongsTo(H); G.belongsTo(H);
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([A.bulkCreate([
A.bulkCreate([
{}, {},
{}, {},
{}, {},
...@@ -557,8 +545,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -557,8 +545,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{} {}
]).then(() => { ]).then(() => {
return A.findAll(); return A.findAll();
}), }), (function(singles) {
(function(singles) {
let promise = Promise.resolve(), let promise = Promise.resolve(),
previousInstance, previousInstance,
b; b;
...@@ -587,8 +574,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -587,8 +574,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}); });
return promise; return promise;
})([B, C, D, E, F, G, H]) })([B, C, D, E, F, G, H])]).then(([as, b]) => {
).then(([as, b]) => {
return Promise.all(as.map(a => { return Promise.all(as.map(a => {
return a.setB(b); return a.setB(b);
})); }));
...@@ -665,7 +651,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -665,7 +651,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
const order2 = results.orders[1]; const order2 = results.orders[1];
const order3 = results.orders[2]; const order3 = results.orders[2];
return Promise.join( return Promise.all([
user1.setItemA(item1), user1.setItemA(item1),
user1.setItemB(item2), user1.setItemB(item2),
user1.setOrder(order3), user1.setOrder(order3),
...@@ -675,7 +661,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -675,7 +661,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
user3.setItemA(item1), user3.setItemA(item1),
user3.setItemB(item4), user3.setItemB(item4),
user3.setOrder(order1) user3.setOrder(order1)
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
'include': [ 'include': [
...@@ -729,14 +715,14 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -729,14 +715,14 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Tag.findAll(); return Tag.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.products[0].addTag(results.tags[0], { through: { priority: 1 } }), results.products[0].addTag(results.tags[0], { through: { priority: 1 } }),
results.products[0].addTag(results.tags[1], { through: { priority: 2 } }), results.products[0].addTag(results.tags[1], { through: { priority: 2 } }),
results.products[1].addTag(results.tags[1], { through: { priority: 1 } }), results.products[1].addTag(results.tags[1], { through: { priority: 1 } }),
results.products[2].addTag(results.tags[0], { through: { priority: 3 } }), results.products[2].addTag(results.tags[0], { through: { priority: 3 } }),
results.products[2].addTag(results.tags[1], { through: { priority: 1 } }), results.products[2].addTag(results.tags[1], { through: { priority: 1 } }),
results.products[2].addTag(results.tags[2], { through: { priority: 2 } }) results.products[2].addTag(results.tags[2], { through: { priority: 2 } })
); ]);
}).then(() => { }).then(() => {
return Product.findAll({ return Product.findAll({
include: [ include: [
...@@ -809,10 +795,10 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -809,10 +795,10 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return User.findAll(); return User.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.users[0].setGroup(results.groups[1]), results.users[0].setGroup(results.groups[1]),
results.users[1].setGroup(results.groups[0]) results.users[1].setGroup(results.groups[0])
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
...@@ -847,10 +833,10 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -847,10 +833,10 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return User.findAll(); return User.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.users[0].setGroup(results.groups[1]), results.users[0].setGroup(results.groups[1]),
results.users[1].setGroup(results.groups[0]) results.users[1].setGroup(results.groups[0])
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
...@@ -931,13 +917,13 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -931,13 +917,13 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Category.findAll(); return Category.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.users[0].setGroup(results.groups[1]), results.users[0].setGroup(results.groups[1]),
results.users[1].setGroup(results.groups[0]), results.users[1].setGroup(results.groups[0]),
Promise.all(results.groups.map(group => { Promise.all(results.groups.map(group => {
return group.setCategories(results.categories); return group.setCategories(results.categories);
})) }))
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
...@@ -984,13 +970,13 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -984,13 +970,13 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Category.findAll(); return Category.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.users[0].setTeam(results.groups[1]), results.users[0].setTeam(results.groups[1]),
results.users[1].setTeam(results.groups[0]), results.users[1].setTeam(results.groups[0]),
Promise.all(results.groups.map(group => { Promise.all(results.groups.map(group => {
return group.setTags(results.categories); return group.setTags(results.categories);
})) }))
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
...@@ -1037,13 +1023,13 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -1037,13 +1023,13 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Category.findAll(); return Category.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.users[0].setGroup(results.groups[1]), results.users[0].setGroup(results.groups[1]),
results.users[1].setGroup(results.groups[0]), results.users[1].setGroup(results.groups[0]),
Promise.all(results.groups.map(group => { Promise.all(results.groups.map(group => {
return group.setCategories(results.categories); return group.setCategories(results.categories);
})) }))
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
...@@ -1083,10 +1069,10 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -1083,10 +1069,10 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return User.findAll(); return User.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.users[1].setLeaderOf(results.projects[1]), results.users[1].setLeaderOf(results.projects[1]),
results.users[0].setLeaderOf(results.projects[0]) results.users[0].setLeaderOf(results.projects[0])
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
...@@ -1132,14 +1118,14 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -1132,14 +1118,14 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Tag.findAll(); return Tag.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.products[0].addTag(results.tags[0], { priority: 1 }), results.products[0].addTag(results.tags[0], { priority: 1 }),
results.products[0].addTag(results.tags[1], { priority: 2 }), results.products[0].addTag(results.tags[1], { priority: 2 }),
results.products[1].addTag(results.tags[1], { priority: 1 }), results.products[1].addTag(results.tags[1], { priority: 1 }),
results.products[2].addTag(results.tags[0], { priority: 3 }), results.products[2].addTag(results.tags[0], { priority: 3 }),
results.products[2].addTag(results.tags[1], { priority: 1 }), results.products[2].addTag(results.tags[1], { priority: 1 }),
results.products[2].addTag(results.tags[2], { priority: 2 }) results.products[2].addTag(results.tags[2], { priority: 2 })
); ]);
}).then(() => { }).then(() => {
return Product.findAll({ return Product.findAll({
include: [ include: [
...@@ -1297,12 +1283,12 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -1297,12 +1283,12 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return User.findAll(); return User.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.users[0].setGroup(results.groups[0]), results.users[0].setGroup(results.groups[0]),
results.users[1].setGroup(results.groups[0]), results.users[1].setGroup(results.groups[0]),
results.users[2].setGroup(results.groups[0]), results.users[2].setGroup(results.groups[0]),
results.users[3].setGroup(results.groups[1]) results.users[3].setGroup(results.groups[1])
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
...@@ -1639,12 +1625,12 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -1639,12 +1625,12 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Category.belongsTo(Post); Category.belongsTo(Post);
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
Post.create({ 'public': true }), Post.create({ 'public': true }),
Post.create({ 'public': true }), Post.create({ 'public': true }),
Post.create({ 'public': true }), Post.create({ 'public': true }),
Post.create({ 'public': true }) Post.create({ 'public': true })
).then(posts => { ]).then(posts => {
return Promise.all(posts.slice(1, 3).map(post => { return Promise.all(posts.slice(1, 3).map(post => {
return post.createCategory({ slug: 'food' }); return post.createCategory({ slug: 'food' });
})); }));
...@@ -1779,18 +1765,18 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -1779,18 +1765,18 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Company.hasMany(User); Company.hasMany(User);
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
User.create({ lastName: 'Albertsen' }), User.create({ lastName: 'Albertsen' }),
User.create({ lastName: 'Zenith' }), User.create({ lastName: 'Zenith' }),
User.create({ lastName: 'Hansen' }), User.create({ lastName: 'Hansen' }),
Company.create({ rank: 1 }), Company.create({ rank: 1 }),
Company.create({ rank: 2 }) Company.create({ rank: 2 })
).then(([albertsen, zenith, hansen, company1, company2]) => { ]).then(([albertsen, zenith, hansen, company1, company2]) => {
return Promise.join( return Promise.all([
albertsen.setCompany(company1), albertsen.setCompany(company1),
zenith.setCompany(company2), zenith.setCompany(company2),
hansen.setCompany(company2) hansen.setCompany(company2)
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
......
...@@ -32,28 +32,24 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -32,28 +32,24 @@ describe(Support.getTestDialectTeaser('Include'), () => {
// Sync them // Sync them
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
// Create an enviroment // Create an enviroment
return Promise.join( return Promise.all([Project.bulkCreate([
Project.bulkCreate([
{ id: 1, name: 'No tasks' }, { id: 1, name: 'No tasks' },
{ id: 2, name: 'No tasks no employees' }, { id: 2, name: 'No tasks no employees' },
{ id: 3, name: 'No employees' }, { id: 3, name: 'No employees' },
{ id: 4, name: 'In progress A' }, { id: 4, name: 'In progress A' },
{ id: 5, name: 'In progress B' }, { id: 5, name: 'In progress B' },
{ id: 6, name: 'In progress C' } { id: 6, name: 'In progress C' }
]), ]), Task.bulkCreate([
Task.bulkCreate([
{ name: 'Important task', fk: 3 }, { name: 'Important task', fk: 3 },
{ name: 'Important task', fk: 4 }, { name: 'Important task', fk: 4 },
{ name: 'Important task', fk: 5 }, { name: 'Important task', fk: 5 },
{ name: 'Important task', fk: 6 } { name: 'Important task', fk: 6 }
]), ]), Employee.bulkCreate([
Employee.bulkCreate([
{ name: 'Jane Doe', fk: 1 }, { name: 'Jane Doe', fk: 1 },
{ name: 'John Doe', fk: 4 }, { name: 'John Doe', fk: 4 },
{ name: 'Jane John Doe', fk: 5 }, { name: 'Jane John Doe', fk: 5 },
{ name: 'John Jane Doe', fk: 6 } { name: 'John Jane Doe', fk: 6 }
]) ])]).then(() =>{
).then(() =>{
//Find all projects with tasks and employees //Find all projects with tasks and employees
const availableProjects = 3; const availableProjects = 3;
const limit = 2; const limit = 2;
...@@ -101,15 +97,13 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -101,15 +97,13 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
// Create an enviroment // Create an enviroment
return Promise.join( return Promise.all([User.bulkCreate([
User.bulkCreate([
{ name: 'Youtube' }, { name: 'Youtube' },
{ name: 'Facebook' }, { name: 'Facebook' },
{ name: 'Google' }, { name: 'Google' },
{ name: 'Yahoo' }, { name: 'Yahoo' },
{ name: '404' } { name: '404' }
]), ]), SomeConnection.bulkCreate([ // Lets count, m: A and u: 1
SomeConnection.bulkCreate([ // Lets count, m: A and u: 1
{ u: 1, m: 'A', fk: 1 }, // 1 // Will be deleted { u: 1, m: 'A', fk: 1 }, // 1 // Will be deleted
{ u: 2, m: 'A', fk: 1 }, { u: 2, m: 'A', fk: 1 },
{ u: 3, m: 'A', fk: 1 }, { u: 3, m: 'A', fk: 1 },
...@@ -134,22 +128,18 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -134,22 +128,18 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{ u: 2, m: 'B', fk: 2 }, { u: 2, m: 'B', fk: 2 },
{ u: 1, m: 'A', fk: 4 }, // 4 { u: 1, m: 'A', fk: 4 }, // 4
{ u: 4, m: 'A', fk: 2 } { u: 4, m: 'A', fk: 2 }
]), ]), A.bulkCreate([
A.bulkCreate([
{ name: 'Just' }, { name: 'Just' },
{ name: 'for' }, { name: 'for' },
{ name: 'testing' }, { name: 'testing' },
{ name: 'proposes' }, { name: 'proposes' },
{ name: 'only' } { name: 'only' }
]), ]), B.bulkCreate([
B.bulkCreate([
{ name: 'this should not' }, { name: 'this should not' },
{ name: 'be loaded' } { name: 'be loaded' }
]), ]), C.bulkCreate([
C.bulkCreate([
{ name: 'because we only want A' } { name: 'because we only want A' }
]) ])]).then(() => {
).then(() => {
// Delete some of conns to prove the concept // Delete some of conns to prove the concept
return SomeConnection.destroy({ where: { return SomeConnection.destroy({ where: {
m: 'A', m: 'A',
......
...@@ -151,10 +151,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -151,10 +151,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize return this.sequelize
.sync({ force: true }) .sync({ force: true })
.then(() => { .then(() => {
return Promise.join( return Promise.all([A.create({}), B.create({})]);
A.create({}),
B.create({})
);
}) })
.then(([a, b]) => { .then(([a, b]) => {
return a.addB(b, { through: { name: 'Foobar' } }); return a.addB(b, { through: { name: 'Foobar' } });
...@@ -293,9 +290,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -293,9 +290,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
G.belongsTo(H); G.belongsTo(H);
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([A.create({}), (function(singles) {
A.create({}),
(function(singles) {
let promise = Promise.resolve(), let promise = Promise.resolve(),
previousInstance, previousInstance,
b; b;
...@@ -324,8 +319,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -324,8 +319,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}); });
return promise; return promise;
})([B, C, D, E, F, G, H]) })([B, C, D, E, F, G, H])]).then(([a, b]) => {
).then(([a, b]) => {
return a.setB(b); return a.setB(b);
}).then(() => { }).then(() => {
return A.findOne({ return A.findOne({
......
...@@ -1014,12 +1014,12 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -1014,12 +1014,12 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
return User.findAll(); return User.findAll();
}) })
}).then(results => { }).then(results => {
return Promise.join( return Promise.all([
results.users[1].setGroup(results.groups[0]), results.users[1].setGroup(results.groups[0]),
results.users[2].setGroup(results.groups[0]), results.users[2].setGroup(results.groups[0]),
results.users[3].setGroup(results.groups[1]), results.users[3].setGroup(results.groups[1]),
results.users[0].setGroup(results.groups[0]) results.users[0].setGroup(results.groups[0])
); ]);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
......
...@@ -21,8 +21,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -21,8 +21,7 @@ if (current.dialect.supports.groupedLimit) {
User.Tasks = User.hasMany(Task, { as: 'tasks' }); User.Tasks = User.hasMany(Task, { as: 'tasks' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
id: 1, id: 1,
tasks: [ tasks: [
{}, {},
...@@ -31,16 +30,14 @@ if (current.dialect.supports.groupedLimit) { ...@@ -31,16 +30,14 @@ if (current.dialect.supports.groupedLimit) {
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}), }), User.create({
User.create({
id: 2, id: 2,
tasks: [ tasks: [
{} {}
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}) })]).then(() => {
).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
{ association: User.Tasks, separate: true } { association: User.Tasks, separate: true }
...@@ -193,8 +190,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -193,8 +190,7 @@ if (current.dialect.supports.groupedLimit) {
User.Tasks = User.hasMany(Task, { as: 'tasks', foreignKey: 'userId' }); User.Tasks = User.hasMany(Task, { as: 'tasks', foreignKey: 'userId' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
id: 1, id: 1,
tasks: [ tasks: [
{}, {},
...@@ -203,8 +199,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -203,8 +199,7 @@ if (current.dialect.supports.groupedLimit) {
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}), }), User.create({
User.create({
id: 2, id: 2,
tasks: [ tasks: [
{}, {},
...@@ -214,8 +209,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -214,8 +209,7 @@ if (current.dialect.supports.groupedLimit) {
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}) })]).then(() => {
).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
{ association: User.Tasks, limit: 2 } { association: User.Tasks, limit: 2 }
...@@ -245,8 +239,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -245,8 +239,7 @@ if (current.dialect.supports.groupedLimit) {
Company.Tasks = Company.hasMany(Task, { as: 'tasks' }); Company.Tasks = Company.hasMany(Task, { as: 'tasks' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
id: 1, id: 1,
company: { company: {
tasks: [ tasks: [
...@@ -259,8 +252,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -259,8 +252,7 @@ if (current.dialect.supports.groupedLimit) {
include: [ include: [
{ association: User.Company, include: [Company.Tasks] } { association: User.Company, include: [Company.Tasks] }
] ]
}), }), User.create({
User.create({
id: 2, id: 2,
company: { company: {
tasks: [ tasks: [
...@@ -271,8 +263,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -271,8 +263,7 @@ if (current.dialect.supports.groupedLimit) {
include: [ include: [
{ association: User.Company, include: [Company.Tasks] } { association: User.Company, include: [Company.Tasks] }
] ]
}) })]).then(() => {
).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
{ association: User.Company, include: [ { association: User.Company, include: [
...@@ -306,8 +297,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -306,8 +297,7 @@ if (current.dialect.supports.groupedLimit) {
Task.Project = Task.belongsTo(Project, { as: 'project' }); Task.Project = Task.belongsTo(Project, { as: 'project' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([Company.create({
Company.create({
id: 1, id: 1,
users: [ users: [
{ {
...@@ -326,8 +316,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -326,8 +316,7 @@ if (current.dialect.supports.groupedLimit) {
] } ] }
] } ] }
] ]
}) })]).then(() => {
).then(() => {
return Company.findAll({ return Company.findAll({
include: [ include: [
{ association: Company.Users, include: [ { association: Company.Users, include: [
...@@ -359,8 +348,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -359,8 +348,7 @@ if (current.dialect.supports.groupedLimit) {
Project.Tasks = Project.hasMany(Task, { as: 'tasks' }); Project.Tasks = Project.hasMany(Task, { as: 'tasks' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
id: 1, id: 1,
projects: [ projects: [
{ {
...@@ -382,8 +370,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -382,8 +370,7 @@ if (current.dialect.supports.groupedLimit) {
include: [ include: [
{ association: User.Projects, include: [Project.Tasks] } { association: User.Projects, include: [Project.Tasks] }
] ]
}), }), User.create({
User.create({
id: 2, id: 2,
projects: [ projects: [
{ {
...@@ -398,8 +385,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -398,8 +385,7 @@ if (current.dialect.supports.groupedLimit) {
include: [ include: [
{ association: User.Projects, include: [Project.Tasks] } { association: User.Projects, include: [Project.Tasks] }
] ]
}) })]).then(() => {
).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
{ association: User.Projects, separate: true, include: [ { association: User.Projects, separate: true, include: [
...@@ -445,8 +431,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -445,8 +431,7 @@ if (current.dialect.supports.groupedLimit) {
return Support.dropTestSchemas(this.sequelize).then(() => { return Support.dropTestSchemas(this.sequelize).then(() => {
return this.sequelize.createSchema('archive').then(() => { return this.sequelize.createSchema('archive').then(() => {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([User.create({
User.create({
id: 1, id: 1,
tasks: [ tasks: [
{ id: 1, title: 'b' }, { id: 1, title: 'b' },
...@@ -456,8 +441,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -456,8 +441,7 @@ if (current.dialect.supports.groupedLimit) {
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}), }), User.create({
User.create({
id: 2, id: 2,
tasks: [ tasks: [
{ id: 5, title: 'a' }, { id: 5, title: 'a' },
...@@ -466,8 +450,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -466,8 +450,7 @@ if (current.dialect.supports.groupedLimit) {
] ]
}, { }, {
include: [User.Tasks] include: [User.Tasks]
}) })]);
);
}).then(() => { }).then(() => {
return User.findAll({ return User.findAll({
include: [{ model: Task, limit: 2, as: 'tasks', order: [['id', 'ASC']] }], include: [{ model: Task, limit: 2, as: 'tasks', order: [['id', 'ASC']] }],
......
...@@ -46,10 +46,10 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -46,10 +46,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
this.Course.belongsToMany(this.Student, { through: this.Score, foreignKey: 'CourseId' }); this.Course.belongsToMany(this.Student, { through: this.Score, foreignKey: 'CourseId' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.Student.create({ no: 1, name: 'ryan' }), this.Student.create({ no: 1, name: 'ryan' }),
this.Course.create({ no: 100, name: 'history' }) this.Course.create({ no: 100, name: 'history' })
).then(([student, course]) => { ]).then(([student, course]) => {
return student.addCourse(course, { through: { score: 98, test_value: 1000 } }); return student.addCourse(course, { through: { score: 98, test_value: 1000 } });
}).then(() => { }).then(() => {
expect(callCount).to.equal(1); expect(callCount).to.equal(1);
...@@ -58,10 +58,10 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -58,10 +58,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
}) })
.then(() => { .then(() => {
return Promise.join( return Promise.all([
this.Student.build({ no: 1 }).getCourses({ where: { no: 100 } }), this.Student.build({ no: 1 }).getCourses({ where: { no: 100 } }),
this.Score.findOne({ where: { StudentId: 1, CourseId: 100 } }) this.Score.findOne({ where: { StudentId: 1, CourseId: 100 } })
); ]);
}) })
.then(([courses, score]) => { .then(([courses, score]) => {
expect(score.test_value).to.equal(1001); expect(score.test_value).to.equal(1001);
......
...@@ -542,14 +542,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -542,14 +542,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should work with a belongsTo association getter', function() { it('should work with a belongsTo association getter', function() {
const userId = Math.floor(Math.random() * 100000); const userId = Math.floor(Math.random() * 100000);
return Promise.join( return Promise.all([this.User.create({
this.User.create({
id: userId id: userId
}), }), this.Task.create({
this.Task.create({
user_id: userId user_id: userId
}) })]).then(([user, task]) => {
).then(([user, task]) => {
return Promise.all([user, task.getUser()]); return Promise.all([user, task.getUser()]);
}).then(([userA, userB]) => { }).then(([userA, userB]) => {
expect(userA.get('id')).to.equal(userB.get('id')); expect(userA.get('id')).to.equal(userB.get('id'));
......
...@@ -432,10 +432,10 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -432,10 +432,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
if (current.dialect.supports.transactions) { if (current.dialect.supports.transactions) {
it('works with a transaction', function() { it('works with a transaction', function() {
return this.sequelize.transaction().then(transaction => { return this.sequelize.transaction().then(transaction => {
return Promise.join( return Promise.all([
this.User.findOrCreate({ where: { uniqueName: 'winner' }, transaction }),
this.User.findOrCreate({ where: { uniqueName: 'winner' }, transaction }), this.User.findOrCreate({ where: { uniqueName: 'winner' }, transaction }),
(first, second) => { this.User.findOrCreate({ where: { uniqueName: 'winner' }, transaction })
]).then(([first, second]) => {
const firstInstance = first[0], const firstInstance = first[0],
firstCreated = first[1], firstCreated = first[1],
secondInstance = second[0], secondInstance = second[0],
...@@ -450,8 +450,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -450,8 +450,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(firstInstance.id).to.equal(secondInstance.id); expect(firstInstance.id).to.equal(secondInstance.id);
return transaction.commit(); return transaction.commit();
} });
);
}); });
}); });
} }
...@@ -512,8 +511,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -512,8 +511,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
username: 'gottlieb' username: 'gottlieb'
}); });
}).then(() => { }).then(() => {
return Promise.join( return Promise.all([User.findOrCreate({
User.findOrCreate({
where: { where: {
objectId: 'asdasdasd' objectId: 'asdasdasd'
}, },
...@@ -525,8 +523,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -525,8 +523,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}).catch(err => { }).catch(err => {
expect(err instanceof Sequelize.UniqueConstraintError).to.be.ok; expect(err instanceof Sequelize.UniqueConstraintError).to.be.ok;
expect(err.fields).to.be.ok; expect(err.fields).to.be.ok;
}), }), User.findOrCreate({
User.findOrCreate({
where: { where: {
objectId: 'asdasdasd' objectId: 'asdasdasd'
}, },
...@@ -538,17 +535,16 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -538,17 +535,16 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}).catch(err => { }).catch(err => {
expect(err instanceof Sequelize.UniqueConstraintError).to.be.ok; expect(err instanceof Sequelize.UniqueConstraintError).to.be.ok;
expect(err.fields).to.be.ok; expect(err.fields).to.be.ok;
}) })]);
);
}); });
}); });
// 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() {
return Promise.join( return Promise.all([
this.User.findOrCreate({ where: { uniqueName: 'winner' } }),
this.User.findOrCreate({ where: { uniqueName: 'winner' } }), this.User.findOrCreate({ where: { uniqueName: 'winner' } }),
(first, second) => { this.User.findOrCreate({ where: { uniqueName: 'winner' } })
]).then(([first, second]) => {
const firstInstance = first[0], const firstInstance = first[0],
firstCreated = first[1], firstCreated = first[1],
secondInstance = second[0], secondInstance = second[0],
...@@ -561,19 +557,18 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -561,19 +557,18 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(secondInstance).to.be.ok; expect(secondInstance).to.be.ok;
expect(firstInstance.id).to.equal(secondInstance.id); expect(firstInstance.id).to.equal(secondInstance.id);
} });
);
}); });
}); });
}); });
describe('findCreateFind', () => { describe('findCreateFind', () => {
(dialect !== 'sqlite' ? it : it.skip)('should work with multiple concurrent calls', function() { (dialect !== 'sqlite' ? it : it.skip)('should work with multiple concurrent calls', function() {
return Promise.join( return Promise.all([
this.User.findOrCreate({ where: { uniqueName: 'winner' } }),
this.User.findOrCreate({ where: { uniqueName: 'winner' } }), this.User.findOrCreate({ where: { uniqueName: 'winner' } }),
this.User.findOrCreate({ where: { uniqueName: 'winner' } }), this.User.findOrCreate({ where: { uniqueName: 'winner' } }),
(first, second, third) => { this.User.findOrCreate({ where: { uniqueName: 'winner' } })
]).then(([first, second, third]) => {
const firstInstance = first[0], const firstInstance = first[0],
firstCreated = first[1], firstCreated = first[1],
secondInstance = second[0], secondInstance = second[0],
...@@ -591,8 +586,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -591,8 +586,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(firstInstance.id).to.equal(secondInstance.id); expect(firstInstance.id).to.equal(secondInstance.id);
expect(secondInstance.id).to.equal(thirdInstance.id); expect(secondInstance.id).to.equal(thirdInstance.id);
} });
);
}); });
}); });
...@@ -656,13 +650,10 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -656,13 +650,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
Log.removeAttribute('id'); Log.removeAttribute('id');
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([Log.create({ level: 'info' }), Log.bulkCreate([
Log.create({ level: 'info' }),
Log.bulkCreate([
{ level: 'error' }, { level: 'error' },
{ level: 'debug' } { level: 'debug' }
]) ])]);
);
}).then(() => { }).then(() => {
return Log.findAll(); return Log.findAll();
}).then(logs => { }).then(logs => {
......
...@@ -51,22 +51,22 @@ if (current.dialect.supports['UNION ALL']) { ...@@ -51,22 +51,22 @@ if (current.dialect.supports['UNION ALL']) {
this.User.Tasks = this.User.hasMany(this.Task); this.User.Tasks = this.User.hasMany(this.Task);
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.User.bulkCreate([{ age: -5 }, { age: 45 }, { age: 7 }, { age: -9 }, { age: 8 }, { age: 15 }, { age: -9 }]), this.User.bulkCreate([{ age: -5 }, { age: 45 }, { age: 7 }, { age: -9 }, { age: 8 }, { age: 15 }, { age: -9 }]),
this.Project.bulkCreate([{}, {}]), this.Project.bulkCreate([{}, {}]),
this.Task.bulkCreate([{}, {}]) this.Task.bulkCreate([{}, {}])
); ]);
}) })
.then(() => Promise.all([this.User.findAll(), this.Project.findAll(), this.Task.findAll()])) .then(() => Promise.all([this.User.findAll(), this.Project.findAll(), this.Task.findAll()]))
.then(([users, projects, tasks]) => { .then(([users, projects, tasks]) => {
this.projects = projects; this.projects = projects;
return Promise.join( return Promise.all([
projects[0].setMembers(users.slice(0, 4)), projects[0].setMembers(users.slice(0, 4)),
projects[1].setMembers(users.slice(2)), projects[1].setMembers(users.slice(2)),
projects[0].setParanoidMembers(users.slice(0, 4)), projects[0].setParanoidMembers(users.slice(0, 4)),
projects[1].setParanoidMembers(users.slice(2)), projects[1].setParanoidMembers(users.slice(2)),
users[2].setTasks(tasks) users[2].setTasks(tasks)
); ]);
}); });
}); });
...@@ -218,19 +218,19 @@ if (current.dialect.supports['UNION ALL']) { ...@@ -218,19 +218,19 @@ if (current.dialect.supports['UNION ALL']) {
this.User.Tasks = this.User.hasMany(this.Task); this.User.Tasks = this.User.hasMany(this.Task);
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
this.User.bulkCreate([{}, {}, {}]), this.User.bulkCreate([{}, {}, {}]),
this.Task.bulkCreate([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }, { id: 6 }]) this.Task.bulkCreate([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }, { id: 6 }])
); ]);
}) })
.then(() => Promise.all([this.User.findAll(), this.Task.findAll()])) .then(() => Promise.all([this.User.findAll(), this.Task.findAll()]))
.then(([users, tasks]) => { .then(([users, tasks]) => {
this.users = users; this.users = users;
return Promise.join( return Promise.all([
users[0].setTasks(tasks[0]), users[0].setTasks(tasks[0]),
users[1].setTasks(tasks.slice(1, 4)), users[1].setTasks(tasks.slice(1, 4)),
users[2].setTasks(tasks.slice(4)) users[2].setTasks(tasks.slice(4))
); ]);
}); });
}); });
......
...@@ -210,8 +210,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -210,8 +210,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
describe('find', () => { describe('find', () => {
it('should be possible to query a nested value', function() { it('should be possible to query a nested value', function() {
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Homer', first: 'Homer',
...@@ -219,8 +218,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -219,8 +218,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Nuclear Safety Inspector' employment: 'Nuclear Safety Inspector'
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Marge', first: 'Marge',
...@@ -228,8 +226,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -228,8 +226,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Housewife' employment: 'Housewife'
} }
}) })]).then(() => {
).then(() => {
return this.Event.findAll({ return this.Event.findAll({
where: { where: {
data: { data: {
...@@ -255,14 +252,12 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -255,14 +252,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const now = moment().milliseconds(0).toDate(); const now = moment().milliseconds(0).toDate();
const before = moment().milliseconds(0).subtract(1, 'day').toDate(); const before = moment().milliseconds(0).subtract(1, 'day').toDate();
const after = moment().milliseconds(0).add(1, 'day').toDate(); const after = moment().milliseconds(0).add(1, 'day').toDate();
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
json: { json: {
user: 'Homer', user: 'Homer',
lastLogin: now lastLogin: now
} }
}) })]).then(() => {
).then(() => {
return this.Event.findAll({ return this.Event.findAll({
where: { where: {
json: { json: {
...@@ -298,14 +293,12 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -298,14 +293,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should be possible to query a boolean with array operators', function() { it('should be possible to query a boolean with array operators', function() {
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
json: { json: {
user: 'Homer', user: 'Homer',
active: true active: true
} }
}) })]).then(() => {
).then(() => {
return this.Event.findAll({ return this.Event.findAll({
where: { where: {
json: { json: {
...@@ -341,8 +334,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -341,8 +334,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should be possible to query a nested integer value', function() { it('should be possible to query a nested integer value', function() {
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Homer', first: 'Homer',
...@@ -350,8 +342,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -350,8 +342,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
age: 40 age: 40
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Marge', first: 'Marge',
...@@ -359,8 +350,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -359,8 +350,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
age: 37 age: 37
} }
}) })]).then(() => {
).then(() => {
return this.Event.findAll({ return this.Event.findAll({
where: { where: {
data: { data: {
...@@ -385,8 +375,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -385,8 +375,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should be possible to query a nested null value', function() { it('should be possible to query a nested null value', function() {
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Homer', first: 'Homer',
...@@ -394,8 +383,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -394,8 +383,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Nuclear Safety Inspector' employment: 'Nuclear Safety Inspector'
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Marge', first: 'Marge',
...@@ -403,8 +391,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -403,8 +391,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: null employment: null
} }
}) })]).then(() => {
).then(() => {
return this.Event.findAll({ return this.Event.findAll({
where: { where: {
data: { data: {
...@@ -425,8 +412,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -425,8 +412,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should be possible to query for nested fields with hyphens/dashes, #8718', function() { it('should be possible to query for nested fields with hyphens/dashes, #8718', function() {
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Homer', first: 'Homer',
...@@ -439,8 +425,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -439,8 +425,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Nuclear Safety Inspector' employment: 'Nuclear Safety Inspector'
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Marge', first: 'Marge',
...@@ -448,8 +433,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -448,8 +433,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: null employment: null
} }
}) })]).then(() => {
).then(() => {
return this.Event.findAll({ return this.Event.findAll({
where: { where: {
data: { data: {
...@@ -488,8 +472,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -488,8 +472,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
employment: 'Nuclear Safety Inspector' employment: 'Nuclear Safety Inspector'
} }
}).then(() => { }).then(() => {
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Marge', first: 'Marge',
...@@ -497,8 +480,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -497,8 +480,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Housewife' employment: 'Housewife'
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Bart', first: 'Bart',
...@@ -506,8 +488,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -506,8 +488,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'None' employment: 'None'
} }
}) })]);
);
}).then(() => { }).then(() => {
return this.Event.findAll({ return this.Event.findAll({
where: { where: {
...@@ -555,8 +536,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -555,8 +536,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
employment: 'Nuclear Safety Inspector' employment: 'Nuclear Safety Inspector'
} }
}).then(() => { }).then(() => {
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Marge', first: 'Marge',
...@@ -564,8 +544,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -564,8 +544,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Housewife' employment: 'Housewife'
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Bart', first: 'Bart',
...@@ -573,8 +552,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -573,8 +552,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'None' employment: 'None'
} }
}) })]);
);
}).then(() => { }).then(() => {
return this.Event.findAll({ return this.Event.findAll({
where: { where: {
...@@ -628,8 +606,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -628,8 +606,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
}; };
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Elliot', first: 'Elliot',
...@@ -637,8 +614,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -637,8 +614,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Hacker' employment: 'Hacker'
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Christian', first: 'Christian',
...@@ -646,8 +622,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -646,8 +622,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Hacker' employment: 'Hacker'
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: ' Tyrell', first: ' Tyrell',
...@@ -655,8 +630,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -655,8 +630,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'CTO' employment: 'CTO'
} }
}) })]).then(() => {
).then(() => {
return expect(this.Event.findAll(conditionSearch)).to.eventually.have.length(2); return expect(this.Event.findAll(conditionSearch)).to.eventually.have.length(2);
}).then(() => { }).then(() => {
return this.Event.destroy(conditionSearch); return this.Event.destroy(conditionSearch);
...@@ -753,8 +727,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -753,8 +727,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
employment: 'Nuclear Safety Inspector' employment: 'Nuclear Safety Inspector'
} }
}).then(() => { }).then(() => {
return Promise.join( return Promise.all([this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Marge', first: 'Marge',
...@@ -762,8 +735,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -762,8 +735,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'Housewife' employment: 'Housewife'
} }
}), }), this.Event.create({
this.Event.create({
data: { data: {
name: { name: {
first: 'Bart', first: 'Bart',
...@@ -771,8 +743,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -771,8 +743,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, },
employment: 'None' employment: 'None'
} }
}) })]);
);
}).then(() => { }).then(() => {
if (current.options.dialect === 'sqlite') { if (current.options.dialect === 'sqlite') {
return this.Event.findAll({ return this.Event.findAll({
......
...@@ -487,7 +487,7 @@ if (current.dialect.supports.transactions) { ...@@ -487,7 +487,7 @@ if (current.dialect.supports.transactions) {
}); });
}); });
}; };
return Promise.join(newTransactionFunc(), newTransactionFunc()).then(() => { return Promise.all([newTransactionFunc(), newTransactionFunc()]).then(() => {
return User.findAll().then(users => { return User.findAll().then(users => {
expect(users.length).to.equal(2); expect(users.length).to.equal(2);
}); });
...@@ -510,7 +510,7 @@ if (current.dialect.supports.transactions) { ...@@ -510,7 +510,7 @@ if (current.dialect.supports.transactions) {
}); });
}); });
}; };
return expect(Promise.join(newTransactionFunc(), newTransactionFunc())).to.be.rejectedWith('SQLITE_BUSY: database is locked'); return expect(Promise.all([newTransactionFunc(), newTransactionFunc()])).to.be.rejectedWith('SQLITE_BUSY: database is locked');
}); });
}); });
}); });
...@@ -570,16 +570,14 @@ if (current.dialect.supports.transactions) { ...@@ -570,16 +570,14 @@ if (current.dialect.supports.transactions) {
}).then(() => { }).then(() => {
return this.sequelize.transaction({ isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE }).then(transaction => { return this.sequelize.transaction({ isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE }).then(transaction => {
return User.findAll( { transaction } ) return User.findAll( { transaction } )
.then(() => Promise.join( .then(() => Promise.all([// Update should not succeed before transaction has committed
User.update({ username: 'joe' }, { User.update({ username: 'joe' }, {
where: { where: {
username: 'jan' username: 'jan'
} }
}).then(() => expect(transactionSpy).to.have.been.called ), // Update should not succeed before transaction has committed }).then(() => expect(transactionSpy).to.have.been.called ), delay(2000)
delay(2000)
.then(() => transaction.commit()) .then(() => transaction.commit())
.then(transactionSpy) .then(transactionSpy)]));
));
}); });
}); });
}); });
...@@ -612,8 +610,7 @@ if (current.dialect.supports.transactions) { ...@@ -612,8 +610,7 @@ if (current.dialect.supports.transactions) {
return this.sequelize.transaction({ return this.sequelize.transaction({
isolationLevel: Transaction.ISOLATION_LEVELS.READ_COMMITTED isolationLevel: Transaction.ISOLATION_LEVELS.READ_COMMITTED
}).then(t2 => { }).then(t2 => {
return Promise.join( return Promise.all([User.findOne({
User.findOne({
where: { where: {
username: 'jan' username: 'jan'
}, },
...@@ -624,9 +621,7 @@ if (current.dialect.supports.transactions) { ...@@ -624,9 +621,7 @@ if (current.dialect.supports.transactions) {
return t2.commit().then(() => { return t2.commit().then(() => {
expect(t2Spy).to.have.been.calledAfter(t1Spy); // Find should not succeed before t1 has committed expect(t2Spy).to.have.been.calledAfter(t1Spy); // Find should not succeed before t1 has committed
}); });
}), }), t1Jan.update({
t1Jan.update({
awesome: true awesome: true
}, { }, {
transaction: t1 transaction: t1
...@@ -635,8 +630,7 @@ if (current.dialect.supports.transactions) { ...@@ -635,8 +630,7 @@ if (current.dialect.supports.transactions) {
return delay(2000).then(() => { return delay(2000).then(() => {
return t1.commit(); return t1.commit();
}); });
}) })]);
);
}); });
}); });
}); });
...@@ -695,10 +689,10 @@ if (current.dialect.supports.transactions) { ...@@ -695,10 +689,10 @@ if (current.dialect.supports.transactions) {
Task.belongsToMany(User, { through: 'UserTasks' }); Task.belongsToMany(User, { through: 'UserTasks' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
User.create({ username: 'John' }), User.create({ username: 'John' }),
Task.create({ title: 'Get rich', active: false }), Task.create({ title: 'Get rich', active: false })
(john, task1) => { ]).then(([john, task1]) => {
return john.setTasks([task1]); return john.setTasks([task1]);
}) })
.then(() => { .then(() => {
...@@ -738,11 +732,11 @@ if (current.dialect.supports.transactions) { ...@@ -738,11 +732,11 @@ if (current.dialect.supports.transactions) {
Task.belongsToMany(User, { through: 'UserTasks' }); Task.belongsToMany(User, { through: 'UserTasks' });
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Promise.join( return Promise.all([
User.create({ username: 'John' }), User.create({ username: 'John' }),
Task.create({ title: 'Get rich', active: false }), Task.create({ title: 'Get rich', active: false }),
Task.create({ title: 'Die trying', active: false }), Task.create({ title: 'Die trying', active: false })
(john, task1) => { ]).then(([john, task1]) => {
return john.setTasks([task1]); return john.setTasks([task1]);
}) })
.then(() => { .then(() => {
...@@ -801,8 +795,7 @@ if (current.dialect.supports.transactions) { ...@@ -801,8 +795,7 @@ if (current.dialect.supports.transactions) {
transaction: t1 transaction: t1
}).then(t1Jan => { }).then(t1Jan => {
return this.sequelize.transaction().then(t2 => { return this.sequelize.transaction().then(t2 => {
return Promise.join( return Promise.all([User.findOne({
User.findOne({
where: { where: {
username: 'jan' username: 'jan'
}, },
...@@ -811,8 +804,7 @@ if (current.dialect.supports.transactions) { ...@@ -811,8 +804,7 @@ if (current.dialect.supports.transactions) {
}).then(() => { }).then(() => {
t2Spy(); t2Spy();
return t2.commit(); return t2.commit();
}), }), t1Jan.update({
t1Jan.update({
awesome: true awesome: true
}, { }, {
transaction: t1 transaction: t1
...@@ -822,8 +814,7 @@ if (current.dialect.supports.transactions) { ...@@ -822,8 +814,7 @@ if (current.dialect.supports.transactions) {
expect(t1Spy).to.have.been.calledAfter(t2Spy); expect(t1Spy).to.have.been.calledAfter(t2Spy);
return t1.commit(); return t1.commit();
}); });
}) })]);
);
}); });
}); });
}); });
...@@ -854,8 +845,7 @@ if (current.dialect.supports.transactions) { ...@@ -854,8 +845,7 @@ if (current.dialect.supports.transactions) {
return this.sequelize.transaction({ return this.sequelize.transaction({
isolationLevel: Transaction.ISOLATION_LEVELS.READ_COMMITTED isolationLevel: Transaction.ISOLATION_LEVELS.READ_COMMITTED
}).then(t2 => { }).then(t2 => {
return Promise.join( return Promise.all([User.findOne({
User.findOne({
where: { where: {
username: 'jan' username: 'jan'
}, },
...@@ -873,9 +863,7 @@ if (current.dialect.supports.transactions) { ...@@ -873,9 +863,7 @@ if (current.dialect.supports.transactions) {
expect(t2UpdateSpy).to.have.been.calledAfter(t1Spy); // But the update call should not happen before the first transaction has committed expect(t2UpdateSpy).to.have.been.calledAfter(t1Spy); // But the update call should not happen before the first transaction has committed
}); });
}); });
}), }), t1Jan.update({
t1Jan.update({
awesome: true awesome: true
}, { }, {
transaction: t1 transaction: t1
...@@ -884,8 +872,7 @@ if (current.dialect.supports.transactions) { ...@@ -884,8 +872,7 @@ if (current.dialect.supports.transactions) {
t1Spy(); t1Spy();
return t1.commit(); return t1.commit();
}); });
}) })]);
);
}); });
}); });
}); });
......
...@@ -309,17 +309,13 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -309,17 +309,13 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
it('should allow decimal as scientific notation', () => { it('should allow decimal as scientific notation', () => {
return Promise.join( return Promise.all([expect(User.create({
expect(User.create({
number: '2321312301230128391820e219' number: '2321312301230128391820e219'
})).not.to.be.rejected, })).not.to.be.rejected, expect(User.create({
expect(User.create({
number: '2321312301230128391820e+219' number: '2321312301230128391820e+219'
})).not.to.be.rejected, })).not.to.be.rejected, expect(User.create({
expect(User.create({
number: '2321312301230128391820f219' number: '2321312301230128391820f219'
})).to.be.rejected })).to.be.rejected]);
);
}); });
it('should allow string as a number', () => { it('should allow string as a number', () => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!