diff --git a/src/QueryBuilder/AbstractDQLQueryBuilder.php b/src/QueryBuilder/AbstractDQLQueryBuilder.php index 9119ffa7d..d423bc317 100644 --- a/src/QueryBuilder/AbstractDQLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDQLQueryBuilder.php @@ -496,6 +496,8 @@ protected function defaultConditionClasses(): array 'OR NOT LIKE' => Condition\LikeCondition::class, 'EXISTS' => Condition\ExistsCondition::class, 'NOT EXISTS' => Condition\ExistsCondition::class, + 'ARRAY OVERLAPS' => Condition\ArrayOverlapsCondition::class, + 'JSON OVERLAPS' => Condition\JsonOverlapsCondition::class, ]; } diff --git a/src/QueryBuilder/Condition/AbstractOverlapCondition.php b/src/QueryBuilder/Condition/AbstractOverlapsCondition.php similarity index 90% rename from src/QueryBuilder/Condition/AbstractOverlapCondition.php rename to src/QueryBuilder/Condition/AbstractOverlapsCondition.php index 59786f212..9748626a3 100644 --- a/src/QueryBuilder/Condition/AbstractOverlapCondition.php +++ b/src/QueryBuilder/Condition/AbstractOverlapsCondition.php @@ -6,15 +6,15 @@ use Yiisoft\Db\Exception\InvalidArgumentException; use Yiisoft\Db\Expression\ExpressionInterface; -use Yiisoft\Db\QueryBuilder\Condition\Interface\OverlapConditionInterface; +use Yiisoft\Db\QueryBuilder\Condition\Interface\OverlapsConditionInterface; use function is_iterable; use function is_string; /** - * Condition that's represented `OVERLAP` operator is used to check if a value is between two values. + * The base class for classes representing the array and JSON overlaps conditions. */ -abstract class AbstractOverlapCondition implements OverlapConditionInterface +abstract class AbstractOverlapsCondition implements OverlapsConditionInterface { public function __construct( private string|ExpressionInterface $column, diff --git a/src/QueryBuilder/Condition/ArrayOverlapCondition.php b/src/QueryBuilder/Condition/ArrayOverlapCondition.php deleted file mode 100644 index 7ed26030e..000000000 --- a/src/QueryBuilder/Condition/ArrayOverlapCondition.php +++ /dev/null @@ -1,12 +0,0 @@ -queryBuilder->buildExpression($column); + } + + return $this->queryBuilder->quoter()->quoteColumnName($column); + } +} diff --git a/src/QueryBuilder/Condition/Interface/OverlapConditionInterface.php b/src/QueryBuilder/Condition/Interface/OverlapsConditionInterface.php similarity index 81% rename from src/QueryBuilder/Condition/Interface/OverlapConditionInterface.php rename to src/QueryBuilder/Condition/Interface/OverlapsConditionInterface.php index 8150be752..09f61958e 100644 --- a/src/QueryBuilder/Condition/Interface/OverlapConditionInterface.php +++ b/src/QueryBuilder/Condition/Interface/OverlapsConditionInterface.php @@ -6,7 +6,10 @@ use Yiisoft\Db\Expression\ExpressionInterface; -interface OverlapConditionInterface extends ConditionInterface +/** + * Represents array and JSON overlaps conditions. + */ +interface OverlapsConditionInterface extends ConditionInterface { /** * @return ExpressionInterface|string The column name. If it's an array, a composite `IN` condition will be diff --git a/src/QueryBuilder/Condition/JsonOverlapCondition.php b/src/QueryBuilder/Condition/JsonOverlapCondition.php deleted file mode 100644 index 625db6d96..000000000 --- a/src/QueryBuilder/Condition/JsonOverlapCondition.php +++ /dev/null @@ -1,12 +0,0 @@ - [[null], 1], + 'expression' => [new Expression("'[0,1,2,7]'"), 1], + 'json expression' => [new JsonExpression([0,1,2,7]), 1], + 'query expression' => [(new Query(static::getDb()))->select(new JsonExpression([0,1,2,7])), 1], + ]; + } }