Skip to content

Commit 5ff0704

Browse files
authored
Adapt to split In condition in Yii DB (#351)
1 parent 9886bdd commit 5ff0704

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Builder/InBuilder.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
use Yiisoft\Db\Exception\NotSupportedException;
1111
use Yiisoft\Db\Expression\ExpressionInterface;
1212
use Yiisoft\Db\QueryBuilder\Condition\In;
13+
use Yiisoft\Db\QueryBuilder\Condition\NotIn;
1314

1415
use function array_slice;
1516
use function array_unshift;
1617
use function count;
1718
use function is_array;
1819

1920
/**
20-
* Build an object of {@see In} into SQL expressions for Oracle Server.
21+
* Build an object of {@see In} or {@see NotIn} into SQL expressions for Oracle Server.
2122
*/
2223
final class InBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\InBuilder
2324
{
2425
/**
2526
* The Method builds the raw SQL from the $expression that won't be additionally escaped or quoted.
2627
*
27-
* @param In $expression The expression to build.
28+
* @param In|NotIn $expression The expression to build.
2829
* @param array $params The binding parameters.
2930
*
3031
* @throws Exception
@@ -55,9 +56,12 @@ public function build(ExpressionInterface $expression, array &$params = []): str
5556
*
5657
* @return string|null `null` when split isn't required. Otherwise - built SQL condition.
5758
*/
58-
protected function splitCondition(In $condition, array &$params): string|null
59+
protected function splitCondition(In|NotIn $condition, array &$params): string|null
5960
{
60-
$operator = $condition->operator;
61+
$operator = match ($condition::class) {
62+
In::class => 'IN',
63+
NotIn::class => 'NOT IN',
64+
};
6165
$values = $condition->values;
6266
$column = $condition->column;
6367

src/DQLQueryBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder;
1212
use Yiisoft\Db\QueryBuilder\Condition\In;
1313
use Yiisoft\Db\QueryBuilder\Condition\Like;
14+
use Yiisoft\Db\QueryBuilder\Condition\NotIn;
1415

1516
use function implode;
1617

@@ -84,6 +85,7 @@ protected function defaultExpressionBuilders(): array
8485
return [
8586
...parent::defaultExpressionBuilders(),
8687
In::class => InBuilder::class,
88+
NotIn::class => InBuilder::class,
8789
Like::class => LikeBuilder::class,
8890
];
8991
}

0 commit comments

Comments
 (0)