1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Mysql; |
6
|
|
|
|
7
|
|
|
use Yiisoft\Db\Expression\Expression; |
8
|
|
|
use Yiisoft\Db\Expression\ExpressionBuilder; |
9
|
|
|
use Yiisoft\Db\Expression\JsonExpression; |
10
|
|
|
use Yiisoft\Db\Mysql\Builder\JsonExpressionBuilder; |
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 ctype_digit; |
18
|
183 |
|
|
19
|
|
|
final class DQLQueryBuilder extends AbstractDQLQueryBuilder |
20
|
183 |
|
{ |
21
|
|
|
public function __construct(QueryBuilderInterface $queryBuilder, QuoterInterface $quoter, SchemaInterface $schema) |
22
|
183 |
|
{ |
23
|
9 |
|
parent::__construct($queryBuilder, $quoter, $schema); |
24
|
|
|
} |
25
|
9 |
|
|
26
|
9 |
|
public function buildLimit(Expression|int|null $limit, Expression|int|null $offset): string |
27
|
|
|
{ |
28
|
177 |
|
$sql = ''; |
29
|
|
|
|
30
|
|
|
if ($this->hasLimit($limit)) { |
31
|
|
|
$sql = 'LIMIT ' . (string) $limit; |
32
|
|
|
|
33
|
|
|
if ($this->hasOffset($offset)) { |
34
|
|
|
$sql .= ' OFFSET ' . (string) $offset; |
35
|
|
|
} |
36
|
|
|
} elseif ($this->hasOffset($offset)) { |
37
|
|
|
/** |
38
|
183 |
|
* limit is not optional in MySQL. |
39
|
|
|
* |
40
|
|
|
* http://stackoverflow.com/a/271650/1106908 |
41
|
|
|
* http://dev.mysql.com/doc/refman/5.0/en/select.html#idm47619502796240 |
42
|
|
|
*/ |
43
|
|
|
$sql = "LIMIT $offset, 18446744073709551615"; // 2^64-1 |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return $sql; |
47
|
|
|
} |
48
|
183 |
|
|
49
|
|
|
/** |
50
|
|
|
* Checks to see if the given limit is effective. |
51
|
183 |
|
* |
52
|
|
|
* @param mixed $limit the given limit. |
53
|
|
|
* |
54
|
|
|
* @return bool whether the limit is effective. |
55
|
|
|
*/ |
56
|
|
|
protected function hasLimit(mixed $limit): bool |
57
|
|
|
{ |
58
|
|
|
/** In MySQL limit argument must be non-negative integer constant */ |
59
|
|
|
return ctype_digit((string) $limit); |
60
|
|
|
} |
61
|
183 |
|
|
62
|
|
|
/** |
63
|
|
|
* Checks to see if the given offset is effective. |
64
|
183 |
|
* |
65
|
183 |
|
* @param mixed $offset the given offset. |
66
|
|
|
* |
67
|
|
|
* @return bool whether the offset is effective. |
68
|
|
|
*/ |
69
|
|
|
protected function hasOffset(mixed $offset): bool |
70
|
|
|
{ |
71
|
|
|
/** In MySQL offset argument must be non-negative integer constant */ |
72
|
|
|
$offset = (string) $offset; |
73
|
|
|
return ctype_digit($offset) && $offset !== '0'; |
74
|
355 |
|
} |
75
|
|
|
|
76
|
355 |
|
/** |
77
|
355 |
|
* Contains array of default expression builders. Extend this method and override it, if you want to change default |
78
|
|
|
* expression builders for this query builder. |
79
|
355 |
|
* |
80
|
|
|
* See {@see ExpressionBuilder} docs for details. |
81
|
|
|
*/ |
82
|
|
|
protected function defaultExpressionBuilders(): array |
83
|
|
|
{ |
84
|
|
|
return array_merge( |
85
|
|
|
parent::defaultExpressionBuilders(), |
86
|
|
|
[ |
87
|
|
|
JsonExpression::class => JsonExpressionBuilder::class, |
88
|
|
|
] |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
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