Skip to content

Commit

Permalink
Making test more clear and re-adding missing junction conditions in s…
Browse files Browse the repository at this point in the history
…ubquery

for `notMatching`
  • Loading branch information
lorenzo committed Jun 26, 2016
1 parent 344317d commit 288781c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ORM/Association/BelongsToMany.php
Expand Up @@ -378,7 +378,8 @@ protected function _appendNotMatching($query, $options)

$subquery = $this->find()
->select(array_values($conds))
->where($options['conditions']);
->where($options['conditions'])
->andWhere($this->junctionConditions());

$subquery = $options['queryBuilder']($subquery);

Expand Down
5 changes: 3 additions & 2 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -2995,7 +2995,8 @@ public function testLeftJoinWithNested()
->find()
->select([
'authors.id',
'total_articles' => 'count(tags.id)'])
'tagged_articles' => 'count(tags.id)'
])
->leftJoinWith('articles.tags', function ($q) {
return $q->where(['tags.name' => 'tag3']);
})
Expand All @@ -3007,7 +3008,7 @@ public function testLeftJoinWithNested()
3 => 1,
4 => 0
];
$this->assertEquals($expected, $results->combine('id', 'total_articles')->toArray());
$this->assertEquals($expected, $results->combine('id', 'tagged_articles')->toArray());
}

/**
Expand Down

0 comments on commit 288781c

Please sign in to comment.