Skip to content

Commit

Permalink
Removing exception that prevented matching and contain in the same as…
Browse files Browse the repository at this point in the history
…sociation

This type of conflic is not possible anymore
  • Loading branch information
lorenzo committed Dec 13, 2014
1 parent 6f8c3bd commit 05434ff
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
7 changes: 0 additions & 7 deletions src/ORM/EagerLoader.php
Expand Up @@ -409,13 +409,6 @@ protected function _correctStrategy(&$config, $alias) {
return $config;
}

if (!empty($config['config']['matching'])) {
throw new \RuntimeException(sprintf(
'Cannot use "matching" on "%s" as there is another association with the same alias',
$alias
));
}

$config['canBeJoined'] = false;
$config['config']['strategy'] = $config['instance']::STRATEGY_SELECT;
}
Expand Down
20 changes: 0 additions & 20 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -1996,26 +1996,6 @@ public function testRepeatedAssociationAliases($strategy) {
$this->assertNotEmpty($results[2]['article']);
}

/**
* Tests that it is not allowed to use matching on an association
* that is already added to containments.
*
* @expectedException \RuntimeException
* @expectedExceptionMessage Cannot use "matching" on "Authors" as there is another association with the same alias
* @return void
*/
public function testConflitingAliases() {
$this->markTestIncomplete('Needs an actual conflicting case');
$table = TableRegistry::get('ArticlesTags');
$table->belongsTo('Articles')->target()->belongsTo('Authors');
$table->belongsTo('Tags');
$table->Tags->target()->hasOne('Authors');
$table->find()
->contain(['Articles.Authors'])
->matching('Tags.Authors')
->sql();
}

/**
* Tests that a hasOne association using the select strategy will still have the
* key present in the results when no match is found
Expand Down

0 comments on commit 05434ff

Please sign in to comment.