|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Oracle; |
|
6
|
|
|
|
|
7
|
|
|
use Yiisoft\Db\Oracle\Builder\InConditionBuilder; |
|
8
|
|
|
use Yiisoft\Db\Oracle\Builder\LikeConditionBuilder; |
|
|
|
|
|
|
9
|
|
|
use Yiisoft\Db\Query\Conditions\InCondition; |
|
|
|
|
|
|
10
|
|
|
use Yiisoft\Db\Query\Conditions\LikeCondition; |
|
|
|
|
|
|
11
|
|
|
use Yiisoft\Db\Query\DQLQueryBuilder as AbstractDQLQueryBuilder; |
|
|
|
|
|
|
12
|
|
|
use Yiisoft\Db\Query\QueryBuilderInterface; |
|
13
|
|
|
use Yiisoft\Db\Schema\QuoterInterface; |
|
14
|
|
|
use Yiisoft\Db\Schema\SchemaInterface; |
|
15
|
|
|
|
|
16
|
|
|
use function array_merge; |
|
17
|
|
|
use function implode; |
|
18
|
166 |
|
|
|
19
|
|
|
final class DQLQueryBuilder extends AbstractDQLQueryBuilder |
|
20
|
166 |
|
{ |
|
21
|
|
|
public function __construct( |
|
22
|
166 |
|
QueryBuilderInterface $queryBuilder, |
|
23
|
6 |
|
QuoterInterface $quoter, |
|
24
|
|
|
SchemaInterface $schema |
|
25
|
|
|
) { |
|
26
|
166 |
|
parent::__construct($queryBuilder, $quoter, $schema); |
|
27
|
|
|
} |
|
28
|
166 |
|
|
|
29
|
1 |
|
public function buildOrderByAndLimit(string $sql, array $orderBy, $limit, $offset, array &$params = []): string |
|
30
|
|
|
{ |
|
31
|
|
|
$orderByString = $this->buildOrderBy($orderBy, $params); |
|
32
|
166 |
|
|
|
33
|
9 |
|
if ($orderByString !== '') { |
|
34
|
|
|
$sql .= $this->separator . $orderByString; |
|
35
|
|
|
} |
|
36
|
166 |
|
|
|
37
|
160 |
|
$filters = []; |
|
38
|
|
|
|
|
39
|
|
|
if ($this->hasOffset($offset)) { |
|
40
|
9 |
|
$filters[] = 'rowNumId > ' . (string) $offset; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
if ($this->hasLimit($limit)) { |
|
44
|
|
|
$filters[] = 'rownum <= ' . (string) $limit; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
if (empty($filters)) { |
|
48
|
|
|
return $sql; |
|
49
|
1 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
$filter = implode(' AND ', $filters); |
|
52
|
344 |
|
return <<<SQL |
|
53
|
|
|
WITH USER_SQL AS ($sql), PAGINATION AS (SELECT USER_SQL.*, rownum as rowNumId FROM USER_SQL) |
|
54
|
344 |
|
SELECT * FROM PAGINATION WHERE $filter |
|
55
|
|
|
SQL; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function selectExists(string $rawSql): string |
|
59
|
|
|
{ |
|
60
|
|
|
return 'SELECT CASE WHEN EXISTS(' . $rawSql . ') THEN 1 ELSE 0 END FROM DUAL'; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
protected function defaultExpressionBuilders(): array |
|
64
|
|
|
{ |
|
65
|
|
|
return array_merge(parent::defaultExpressionBuilders(), [ |
|
66
|
|
|
InCondition::class => InConditionBuilder::class, |
|
67
|
|
|
LikeCondition::class => LikeConditionBuilder::class, |
|
68
|
|
|
]); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
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