1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Sqlite\Builder; |
6
|
|
|
|
7
|
|
|
use Traversable; |
8
|
|
|
use Yiisoft\Db\Exception\Exception; |
9
|
|
|
use Yiisoft\Db\Exception\InvalidArgumentException; |
10
|
|
|
use Yiisoft\Db\Exception\InvalidConfigException; |
11
|
|
|
use Yiisoft\Db\Exception\NotSupportedException; |
12
|
|
|
use Yiisoft\Db\Expression\ExpressionInterface; |
13
|
|
|
use Yiisoft\Db\Query\Conditions\Builder\InConditionBuilder as BaseInConditionBuilder; |
|
|
|
|
14
|
|
|
use Yiisoft\Db\Query\QueryBuilderInterface; |
|
|
|
|
15
|
|
|
|
16
|
|
|
use function implode; |
17
|
|
|
use function is_array; |
18
|
|
|
use function str_contains; |
19
|
|
|
|
20
|
|
|
final class InConditionBuilder extends BaseInConditionBuilder |
21
|
|
|
{ |
22
|
|
|
public function __construct(private QueryBuilderInterface $queryBuilder) |
23
|
|
|
{ |
24
|
|
|
parent::__construct($queryBuilder); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Builds SQL for IN condition. |
29
|
|
|
* |
30
|
|
|
* @param string $operator |
31
|
|
|
* @param array|string $columns |
32
|
|
|
* @param ExpressionInterface $values |
33
|
|
|
* @param array $params |
34
|
|
|
* |
35
|
|
|
* @throws Exception|InvalidArgumentException|InvalidConfigException|NotSupportedException |
36
|
|
|
* |
37
|
|
|
* @return string SQL. |
38
|
|
|
*/ |
39
|
|
|
protected function buildSubqueryInCondition( |
40
|
|
|
string $operator, |
41
|
|
|
array|string $columns, |
42
|
|
|
ExpressionInterface $values, |
43
|
|
|
array &$params = [] |
44
|
|
|
): string { |
45
|
|
|
if (is_array($columns)) { |
|
|
|
|
46
|
|
|
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return parent::buildSubqueryInCondition($operator, $columns, $values, $params); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Builds SQL for IN condition. |
54
|
|
|
* |
55
|
|
|
* @param string|null $operator |
56
|
|
|
* @param array|Traversable $columns |
57
|
|
|
* @param array|Traversable $values |
58
|
|
|
* @param array $params |
59
|
|
|
* |
60
|
|
|
* @return string SQL. |
61
|
|
|
*/ |
62
|
|
|
protected function buildCompositeInCondition( |
63
|
|
|
?string $operator, |
64
|
|
|
Traversable|array $columns, |
65
|
|
|
Traversable|array $values, |
66
|
|
|
array &$params = [] |
67
|
|
|
): string { |
68
|
|
|
$quotedColumns = []; |
69
|
|
|
|
70
|
|
|
/** @psalm-var string[]|Traversable $columns */ |
71
|
|
|
foreach ($columns as $i => $column) { |
72
|
|
|
$quotedColumns[$i] = !str_contains($column, '(') |
73
|
|
|
? $this->queryBuilder->quoter()->quoteColumnName($column) : $column; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$vss = []; |
77
|
|
|
|
78
|
|
|
/** @psalm-var string[][] $values */ |
79
|
|
|
foreach ($values as $value) { |
80
|
|
|
$vs = []; |
81
|
|
|
foreach ($columns as $i => $column) { |
82
|
|
|
if (isset($value[$column])) { |
83
|
|
|
$phName = $this->queryBuilder->bindParam($value[$column], $params); |
84
|
|
|
$vs[] = $quotedColumns[$i] . ($operator === 'IN' ? ' = ' : ' != ') . $phName; |
85
|
|
|
} else { |
86
|
|
|
$vs[] = $quotedColumns[$i] . ($operator === 'IN' ? ' IS' : ' IS NOT') . ' NULL'; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
$vss[] = '(' . implode($operator === 'IN' ? ' AND ' : ' OR ', $vs) . ')'; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
return '(' . implode($operator === 'IN' ? ' OR ' : ' AND ', $vss) . ')'; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths