Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
- Chg #366: Rename `DMLQueryBuilder::insertWithReturningPks()` to `DMLQueryBuilder::insertReturningPks()` (@Tigrov)
- Enh #372: Provide `yiisoft/db-implementation` virtual package (@vjik)
- Enh #375: Adapt to `Param` refactoring in `yiisoft/db` package (@vjik)
- Enh #376: Adapt to conditions refactoring in `yiisoft/db` package (@vjik)
- Enh #376, #379: Adapt to conditions refactoring in `yiisoft/db` package (@vjik)

## 1.2.0 March 21, 2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use function str_contains;

/**
* Build an object of {@see \Yiisoft\Db\QueryBuilder\Condition\InCondition} into SQL expressions for MSSQL Server.
* Build an object of {@see \Yiisoft\Db\QueryBuilder\Condition\In} into SQL expressions for MSSQL Server.
*/
final class InConditionBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\InConditionBuilder
final class InBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\InBuilder
{
/**
* Builds SQL for IN condition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Build an object of {@see \Yiisoft\Db\QueryBuilder\Condition\LikeCondition} into SQL expressions for MSSQL Server.
*/
final class LikeConditionBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\LikeConditionBuilder
final class LikeBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\LikeBuilder
{
/**
* @var array Map of chars to their replacements in `LIKE` conditions. By default, it's configured to escape
Expand Down
12 changes: 6 additions & 6 deletions src/DQLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use Yiisoft\Db\Exception\Exception;
use InvalidArgumentException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Mssql\Builder\InConditionBuilder;
use Yiisoft\Db\Mssql\Builder\LikeConditionBuilder;
use Yiisoft\Db\Mssql\Builder\InBuilder;
use Yiisoft\Db\Mssql\Builder\LikeBuilder;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder;
use Yiisoft\Db\QueryBuilder\Condition\InCondition;
use Yiisoft\Db\QueryBuilder\Condition\LikeCondition;
use Yiisoft\Db\QueryBuilder\Condition\In;
use Yiisoft\Db\QueryBuilder\Condition\Like;

use function preg_match;

Expand Down Expand Up @@ -46,8 +46,8 @@ protected function defaultExpressionBuilders(): array
{
return [
...parent::defaultExpressionBuilders(),
InCondition::class => InConditionBuilder::class,
LikeCondition::class => LikeConditionBuilder::class,
In::class => InBuilder::class,
Like::class => LikeBuilder::class,
];
}

Expand Down
18 changes: 5 additions & 13 deletions tests/Builder/InconditionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
namespace Yiisoft\Db\Mssql\Tests\Builder;

use PHPUnit\Framework\TestCase;
use Yiisoft\Db\Exception\Exception;
use InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Mssql\Builder\InConditionBuilder;
use Yiisoft\Db\Mssql\Builder\InBuilder;
use Yiisoft\Db\Mssql\Tests\Support\TestTrait;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\QueryBuilder\Condition\InCondition;
use Yiisoft\Db\QueryBuilder\Condition\In;

/**
* @group mssql
Expand All @@ -23,25 +20,20 @@ final class InconditionBuilderTest extends TestCase
{
use TestTrait;

/**
* @throws Exception
* @throws InvalidArgumentException
* @throws InvalidConfigException
*/
public function testBuildSubqueryInCondition(): void
{
$db = $this->getConnection();
$inCondition = new InCondition(
$inCondition = new In(
['id'],
'in',
(new Query($db))->select('id')->from('users')->where(['active' => 1]),
);

$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage(
'Yiisoft\Db\Mssql\Builder\InConditionBuilder::buildSubqueryInCondition is not supported by MSSQL.'
'Yiisoft\Db\Mssql\Builder\InBuilder::buildSubqueryInCondition is not supported by MSSQL.'
);

(new InConditionBuilder($db->getQueryBuilder()))->build($inCondition);
(new InBuilder($db->getQueryBuilder()))->build($inCondition);
}
}
10 changes: 5 additions & 5 deletions tests/Provider/QueryBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Yiisoft\Db\Mssql\Column\ColumnBuilder;
use Yiisoft\Db\Mssql\Tests\Support\TestTrait;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\QueryBuilder\Condition\InCondition;
use Yiisoft\Db\QueryBuilder\Condition\In;
use Yiisoft\Db\Tests\Support\TraversableObject;

use function array_replace;
Expand Down Expand Up @@ -240,20 +240,20 @@ public static function buildCondition(): array
{
$buildCondition = parent::buildCondition();

$buildCondition['inCondition-custom-1'] = [new InCondition(['id', 'name'], 'in', []), '()', []];
$buildCondition['inCondition-custom-1'] = [new In(['id', 'name'], 'in', []), '()', []];
$buildCondition['inCondition-custom-3'] = [
new InCondition(['id', 'name'], 'in', [['id' => 1]]),
new In(['id', 'name'], 'in', [['id' => 1]]),
'(([id] = :qp0 AND [name] IS NULL))',
[':qp0' => 1],
];
$buildCondition['inCondition-custom-4'] = [
new InCondition(['id', 'name'], 'in', [['name' => 'oy']]),
new In(['id', 'name'], 'in', [['name' => 'oy']]),
'(([id] IS NULL AND [name] = :qp0))',
[':qp0' => 'oy'],
];

$buildCondition['inCondition-custom-5'] = [
new InCondition(['id', 'name'], 'in', [['id' => 1, 'name' => 'oy']]),
new In(['id', 'name'], 'in', [['id' => 1, 'name' => 'oy']]),
'(([id] = :qp0 AND [name] = :qp1))',
[':qp0' => 1, ':qp1' => 'oy'],
];
Expand Down
Loading