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

Commit ab741606 by Mick Hansen

Merge branch 'master' of https://github.com/cmwilhelm/sequelize into cmwilhelm-master

2 parents e763b0de 52311582
...@@ -53,7 +53,38 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -53,7 +53,38 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}) })
}) });
it("should still pull the main record when an included model is not required and has where restrictions without matches", function () {
var DT = DataTypes,
S = this.sequelize,
A = S.define( 'A', {name: DT.STRING(40)} ),
B = S.define( 'B', {name: DT.STRING(40)} );
A.hasMany(B);
B.hasMany(A);
return S
.sync({force: true})
.then(function () {
return A.create({
name: 'Foobar'
});
})
.then(function () {
return A.find({
where: {name: 'Foobar'},
include: [
{model: B, where: {name: 'idontexist'}, require: false}
]
});
})
.then(function (a) {
expect(a).to.not.equal(null);
expect(a.get('bs')).to.deep.equal([]);
});
});
});
})
}) })
\ No newline at end of file
...@@ -1679,5 +1679,38 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -1679,5 +1679,38 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}) })
}) })
}) })
it("should still pull the main record(s) when an included model is not required and has where restrictions without matches", function () {
var DT = DataTypes,
S = this.sequelize,
A = S.define( 'A', {name: DT.STRING(40)} ),
B = S.define( 'B', {name: DT.STRING(40)} );
A.hasMany(B);
B.hasMany(A);
return S
.sync({force: true})
.then(function () {
return A.create({
name: 'Foobar'
});
})
.then(function () {
return A.findAll({
where: {name: 'Foobar'},
include: [
{model: B, where: {name: 'idontexist'}, require: false}
]
});
})
.then(function (as) {
expect(as.length).to.equal(1);
expect(as[0].get('bs')).deep.equal([]);
});
});
}) })
}) })
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!