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

Commit 33caab9f by José Moreira

Eager Loading of non required but conditionable

Fixes #1614
1 parent d311b2c2
......@@ -779,7 +779,7 @@ module.exports = (function() {
joinQueryItem += " AND "+self.getWhereConditions(include.where, self.sequelize.literal(self.quoteIdentifier(as)), include.daoFactory, whereOptions)
// If its a multi association we need to add a where query to the main where (executed in the subquery)
if (subQuery && association.isMultiAssociation) {
if (subQuery && association.isMultiAssociation && include.required) {
if (!options.where) options.where = {}
// Creating the as-is where for the subQuery, checks that the required association exists
......
......@@ -701,16 +701,16 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
it("get associated objects with an eager load with conditions but not required", function(done) {
var Label = this.sequelize.define('Label', { 'title': DataTypes.STRING, 'isActive': DataTypes.BOOLEAN })
, Task = this.Task
, User = this.User
Task.hasMany(Label)
Label.hasMany(Task)
Label.sync({ force: true }).success(function() {
this.User.find({
User.find({
where: { username: 'John'},
include: [
{ model: this.Task, required: false, include: [
{ model: this.Label, required: false, where: { active: 1 } }
{ model: Task, required: false, include: [
{ model: Label, required: false, where: { isActive: 1 } }
]}
]
}).done(function (err, john) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!