Skip to content

Commit 386ef1d

Browse files
authored
Adapt to changes in Yii DB (#350)
1 parent c35a84d commit 386ef1d

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
- Enh #340: Adapt to `Param` refactoring in `yiisoft/db` package (@vjik)
5656
- Enh #341, #342, #345: Adapt to conditions refactoring in `yiisoft/db` package (@vjik)
5757
- Enh #348: Remove `TableSchema` class and refactor `Schema` class (@Tigrov)
58+
- Enh #350: Adapt to `Like` changes in `yiisoft/db` package (@vjik)
5859

5960
## 1.3.0 March 21, 2024
6061

src/Builder/LikeBuilder.php

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Yiisoft\Db\Expression\ExpressionInterface;
88
use Yiisoft\Db\QueryBuilder\Condition\Like;
99
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
10-
use Yiisoft\Db\Schema\Quoter;
1110

1211
use function substr;
1312

@@ -28,29 +27,23 @@ final class LikeBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\LikeB
2827
'!' => '!!',
2928
];
3029

31-
public function __construct(private QueryBuilderInterface $queryBuilder)
32-
{
30+
public function __construct(
31+
private readonly QueryBuilderInterface $queryBuilder,
32+
) {
3333
parent::__construct($queryBuilder, $this->getEscapeSql());
34-
}
35-
36-
public function build(ExpressionInterface $expression, array &$params = []): string
37-
{
38-
if (!isset($this->escapingReplacements['\\'])) {
39-
/*
40-
* Different pdo_oci8 versions may or may not implement `PDO::quote()`, so {@see Quoter::quoteValue()} may or
41-
* may not quote `\`.
42-
*/
43-
$this->escapingReplacements['\\'] = substr($this->queryBuilder->getQuoter()->quoteValue('\\'), 1, -1);
44-
}
4534

46-
return parent::build($expression, $params);
35+
/**
36+
* Different pdo_oci8 versions may or may not implement `PDO::quote()`, so {@see Quoter::quoteValue()} may or
37+
* may not quote `\`.
38+
*/
39+
$this->escapingReplacements['\\'] = substr($this->queryBuilder->getQuoter()->quoteValue('\\'), 1, -1);
4740
}
4841

49-
protected function prepareColumn(Like $expression, array &$params): string
42+
protected function prepareColumn(Like $condition, array &$params): string
5043
{
51-
$column = parent::prepareColumn($expression, $params);
44+
$column = parent::prepareColumn($condition, $params);
5245

53-
if ($expression->caseSensitive === false) {
46+
if ($condition->caseSensitive === false) {
5447
$column = 'LOWER(' . $column . ')';
5548
}
5649

@@ -59,13 +52,12 @@ protected function prepareColumn(Like $expression, array &$params): string
5952

6053
protected function preparePlaceholderName(
6154
string|ExpressionInterface $value,
62-
Like $expression,
63-
?array $escape,
55+
Like $condition,
6456
array &$params,
6557
): string {
66-
$placeholderName = parent::preparePlaceholderName($value, $expression, $escape, $params);
58+
$placeholderName = parent::preparePlaceholderName($value, $condition, $params);
6759

68-
if ($expression->caseSensitive === false) {
60+
if ($condition->caseSensitive === false) {
6961
$placeholderName = 'LOWER(' . $placeholderName . ')';
7062
}
7163

0 commit comments

Comments
 (0)