Skip to content
Permalink
Browse files

Fixes #6223

  • Loading branch information...
lorenzo committed Mar 31, 2015
1 parent 5e72390 commit b33b703ac9908d847ccc0955e11d1aa59b9d34c6
Showing with 24 additions and 0 deletions.
  1. +3 −0 src/ORM/ResultSet.php
  2. +21 −0 tests/TestCase/ORM/QueryRegressionTest.php
@@ -383,6 +383,9 @@ protected function _calculateColumnMap()
}
foreach ($this->_matchingMap as $alias => $assoc) {
if (!isset($map[$alias])) {
continue;
}
$this->_matchingMapColumns[$alias] = $map[$alias];
unset($map[$alias]);
}
@@ -818,4 +818,25 @@ public function testContainWithNoFields()
$this->assertEquals([3 => 1, 4 => 1, 5 => 1], $results->toArray());
}
/**
* Tests that using matching and selecting no fields for that association
* will no trigger any errors and fetch the right results
*
* @see https://github.com/cakephp/cakephp/issues/6223
* @return void
*/
public function testMatchingWithNoFields()
{
$table = TableRegistry::get('Users');
$table->hasMany('Comments');
$results = $table->find()
->select(['Users.id'])
->matching('Comments', function ($q) {
return $q->where(['Comments.id' => 1]);
})
->extract('id')
->toList();
$this->assertEquals([2], $results);
}
}

0 comments on commit b33b703

Please sign in to comment.
You can’t perform that action at this time.