Commit 7da3449d by Ivan Pomortsev

Update QueryBuilder.php

Change buildUnion method to be ready to accept parameters in <code>['all' => $all, 'query' => $query]</code> format for division to "UNION" and "UNION ALL" constructions.
parent 5f3d601b
......@@ -748,9 +748,14 @@ class QueryBuilder extends \yii\base\Object
*/
$reducer = function($left, $right)
{
$all = $right->params['all'];
list($right, $params) = $this->build($right);
return $left . ' UNION ' . ($all ? 'ALL ' : ' ') . $right . ' )';
if(is_array($left))
$left = $left['query'];
$all = false;
if(is_array($right)) {
$all = $right['all'];
$right = $right['query'];
}
return $left . ' UNION ' . ($all ? 'ALL ' : '') . '( ' . $right . ' )';
};
foreach ($unions as $i => $union) {
......@@ -758,6 +763,7 @@ class QueryBuilder extends \yii\base\Object
// save the original parameters so that we can restore them later to prevent from modifying the query object
$originalParams = $union->params;
$union->addParams($params);
list ($unions[$i]['query'], $params) = $this->build($query);
$union->params = $originalParams;
}
}
......
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