Commit 2150fa32 by Qiang Xue

Fixes #4970: `joinWith()` called by a relation was ignored by `yii\db\ActiveQuery`

parent 70ed5d5c
...@@ -91,6 +91,7 @@ Yii Framework 2 Change Log ...@@ -91,6 +91,7 @@ Yii Framework 2 Change Log
- Bug #4880: Return value of yii\web\Request::getPrefferedLanguage() was a normalized value instead of a valid language value from the input array (cebe) - Bug #4880: Return value of yii\web\Request::getPrefferedLanguage() was a normalized value instead of a valid language value from the input array (cebe)
- Bug #4920: `yii\filters\auth\CompositeAuth` should not trigger error as long as one of the methods succeeds (qiangxue) - Bug #4920: `yii\filters\auth\CompositeAuth` should not trigger error as long as one of the methods succeeds (qiangxue)
- Bug #4954: MSSQL column comments are not retrieved correctly (SerjRamone) - Bug #4954: MSSQL column comments are not retrieved correctly (SerjRamone)
- Bug #4970: `joinWith()` called by a relation was ignored by `yii\db\ActiveQuery` (stepanselyuk)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark) - Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul) - Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul)
- Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue) - Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
......
...@@ -482,9 +482,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -482,9 +482,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$relations[$fullName] = $relation = $primaryModel->getRelation($name); $relations[$fullName] = $relation = $primaryModel->getRelation($name);
if ($callback !== null) { if ($callback !== null) {
call_user_func($callback, $relation); call_user_func($callback, $relation);
if(is_array($relation->joinWith)) {
$relation->buildJoinWith();
} }
if (!empty($relation->joinWith)) {
$relation->buildJoinWith();
} }
$this->joinWithRelation($parent, $relation, $this->getJoinType($joinType, $fullName)); $this->joinWithRelation($parent, $relation, $this->getJoinType($joinType, $fullName));
} }
......
...@@ -601,7 +601,7 @@ class ActiveRecordTest extends DatabaseTestCase ...@@ -601,7 +601,7 @@ class ActiveRecordTest extends DatabaseTestCase
$model->char_col = '1337'; $model->char_col = '1337';
$model->char_col2 = 'test'; $model->char_col2 = 'test';
$model->char_col3 = 'test123'; $model->char_col3 = 'test123';
$model->float_col = 1337.42; $model->float_col = 3.742;
$model->float_col2 = 42.1337; $model->float_col2 = 42.1337;
$model->bool_col = true; $model->bool_col = true;
$model->bool_col2 = false; $model->bool_col2 = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment