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

Commit 672116ff by Chris Wilhelm

Unit tests added for .find() and .findAll(), with included relation using own wh…

…ere and require: false.
1 parent 34fddc2a
Showing with 36 additions and 0 deletions
...@@ -194,6 +194,24 @@ describe(Support.getTestDialectTeaser("Model"), function () { ...@@ -194,6 +194,24 @@ describe(Support.getTestDialectTeaser("Model"), function () {
}); });
}); });
it('should work with where on includes for find when require is set to false and included relation has no results', function () {
var self = this;
return this.User.create({
name: 'Barfoo'
}).then(function (user) {
return self.User.find({
where: {name: 'Barfoo'},
include: [
{model: self.Task, where: {title: 'idontexist'}, require: false}
]
});
}).then(function (user) {
expect(user).to.not.equal(null);
expect(user.get('tasks')).to.deep.equal([]);
});
});
it('should work with where on includes for findAll', function () { it('should work with where on includes for findAll', function () {
var self = this; var self = this;
...@@ -224,6 +242,24 @@ describe(Support.getTestDialectTeaser("Model"), function () { ...@@ -224,6 +242,24 @@ describe(Support.getTestDialectTeaser("Model"), function () {
}); });
}); });
it('should work with where on includes for findAll when require is set to false and included relation has no results', function () {
var self = this;
return this.User.create({
name: 'Barfoo'
}).then(function (user) {
return self.User.findAll({
where: {name: 'Barfoo'},
include: [
{model: self.Task, where: {title: 'idontexist'}, require: false}
]
});
}).then(function (users) {
expect(users.length).to.equal(1);
expect(users[0].get('tasks')).deep.equal([]);
});
});
it('should work with a simple where', function () { it('should work with a simple where', function () {
var self = this; var self = this;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!