Skip to content
Permalink
Browse files

Making Select startegy the default (again) having subqueries as

a default would require people to use latest versions of Mysql or
Postgres, which is rather rare
  • Loading branch information...
lorenzo committed May 29, 2013
1 parent 1e8e702 commit e6cabd3428e2d78e75241030951df05e28e4c8c5
@@ -46,12 +46,11 @@ class BelongsToMany extends Association {
protected $_joinType = 'INNER';
/**
* The strategy name to be used to fetch associated records. Some association
* types might not implement but one strategy to fetch records.
* The strategy name to be used to fetch associated records.
*
* @var string
*/
protected $_strategy = parent::STRATEGY_SUBQUERY;
protected $_strategy = parent::STRATEGY_SELECT;
/**
* Pivot table instance
@@ -35,12 +35,11 @@ class HasMany extends Association {
protected $_joinType = 'INNER';
/**
* The strategy name to be used to fetch associated records. Some association
* types might not implement but one strategy to fetch records.
* The strategy name to be used to fetch associated records.
*
* @var string
*/
protected $_strategy = parent::STRATEGY_SUBQUERY;
protected $_strategy = parent::STRATEGY_SELECT;
/**
* Eager loads a list of records in the target table that are related to another
@@ -84,11 +84,11 @@ public function testSort() {
*/
public function testRequiresKeys() {
$assoc = new BelongsToMany('Test');
$this->assertFalse($assoc->requiresKeys());
$assoc->strategy(BelongsToMany::STRATEGY_SELECT);
$this->assertTrue($assoc->requiresKeys());
$assoc->strategy(BelongsToMany::STRATEGY_SUBQUERY);
$this->assertFalse($assoc->requiresKeys());
$assoc->strategy(BelongsToMany::STRATEGY_SELECT);
$this->assertTrue($assoc->requiresKeys());
}
/**
@@ -86,11 +86,11 @@ public function testSort() {
*/
public function testRequiresKeys() {
$assoc = new HasMany('Test');
$this->assertFalse($assoc->requiresKeys());
$assoc->strategy(HasMany::STRATEGY_SELECT);
$this->assertTrue($assoc->requiresKeys());
$assoc->strategy(HasMany::STRATEGY_SUBQUERY);
$this->assertFalse($assoc->requiresKeys());
$assoc->strategy(HasMany::STRATEGY_SELECT);
$this->assertTrue($assoc->requiresKeys());
}
/**
@@ -317,19 +317,21 @@ public function testEagerLoaderSubquery() {
->with(['Article.author_id in' => $expected])
->will($this->returnValue($query));
$callable = $association->eagerLoader(['query' => $parent]);
$callable = $association->eagerLoader([
'query' => $parent, 'strategy' => HasMany::STRATEGY_SUBQUERY
]);
$row = ['Author__id' => 1, 'username' => 'author 1'];
$result = $callable($row);
$row['Author__Article'] = [
['id' => 2, 'title' => 'article 2', 'author_id' => 1]
];
];
$this->assertEquals($row, $result);
$row = ['Author__id' => 2, 'username' => 'author 2'];
$result = $callable($row);
$row['Author__Article'] = [
['id' => 1, 'title' => 'article 1', 'author_id' => 2]
];
];
$this->assertEquals($row, $result);
}

0 comments on commit e6cabd3

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