Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions tests/Provider/QueryBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Yiisoft\Db\Constant\ReferentialAction;
use Yiisoft\Db\Constraint\ForeignKey;
use Yiisoft\Db\Expression\Statement\CaseX;
use Yiisoft\Db\Expression\Statement\When;
use Yiisoft\Db\Expression\Statement\WhenThen;
use Yiisoft\Db\Expression\Value\ArrayValue;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Expression\Function\ArrayMerge;
Expand Down Expand Up @@ -462,20 +462,23 @@ public static function caseXBuilder(): array
$data = parent::caseXBuilder();

$data['with case expression'] = [
$data['with case expression'][0] = new CaseX(
'(1 + 2)',
when1: new When(1, 1),
when2: new When(2, new Expression('2')),
when3: new When(3, '(2 + 1)'),
new CaseX(
'column_name',
when1: new WhenThen(1, 1),
when2: new WhenThen(2, new Expression('(1 + 1)')),
else: new Expression('to_number(:qp0)', [':qp0' => $param = new Param(4, DataType::INTEGER)]),
),
'CASE (1 + 2) WHEN 1 THEN 1 WHEN 2 THEN 2 WHEN 3 THEN (2 + 1) ELSE to_number(:qp0) END',
[':qp0' => $param],
3,
'CASE "column_name" WHEN 1 THEN 1 WHEN 2 THEN (1 + 1) ELSE to_number(:qp0) END',
[
':qp0' => $param,
],
2,
];
$data['without case expression'][1] = 'CASE WHEN "column_name" = 1 THEN :qp0'
. ' WHEN "column_name" = 2 THEN (SELECT :qp1 FROM DUAL) END';

unset($data['with case condition']);

return $data;
}

Expand Down