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

Commit e847cd97 by Mick Hansen

unit test possible covering #2029

1 parent 6b7e3e0a
Showing with 32 additions and 0 deletions
...@@ -49,7 +49,39 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -49,7 +49,39 @@ describe(Support.getTestDialectTeaser("Include"), function () {
done(); done();
}); });
}); });
});
it('should include a model with a where condition but no required', function () {
var User = this.sequelize.define('User', {}, { paranoid: false })
, Task = this.sequelize.define('Task', {
deletedAt: {
type: DataTypes.DATE
}
}, { paranoid: false });
User.hasMany(Task, {foreignKey: 'userId'});
Task.belongsTo(User, {foreignKey: 'userId'});
return this.sequelize.sync({
force: true
}).then(function () {
return User.create();
}).then(function (user) {
return Task.bulkCreate([
{userId: user.get('id'), deletedAt: new Date()},
{userId: user.get('id'), deletedAt: new Date()},
{userId: user.get('id'), deletedAt: new Date()}
]);
}).then(function () {
return User.find({
include: [
{model: Task, where: {deletedAt: null}, required: false}
]
});
}).then(function (user) {
expect(user).to.be.ok;
expect(user.Tasks.length).to.equal(0);
});
}); });
it("should still pull the main record when an included model is not required and has where restrictions without matches", function () { it("should still pull the main record when an included model is not required and has where restrictions without matches", function () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!