Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
RawSQLExpression | |
0.00% |
0 / 3 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
toSql | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
toGeneralizedSql | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Wikimedia\Rdbms; |
4 | |
5 | use Wikimedia\Rdbms\Database\DbQuoter; |
6 | |
7 | /** |
8 | * Raw SQL value to be used in expression builders |
9 | * |
10 | * @note This should be used very rarely and NEVER with user input. |
11 | * |
12 | * @newable |
13 | * @since 1.42 |
14 | */ |
15 | class RawSQLExpression extends Expression { |
16 | private string $expression = ''; |
17 | |
18 | /** |
19 | * This should be used very rarely and NEVER with user input. |
20 | * |
21 | * Most common usecases include comparing two columns |
22 | * or function calls (e.g. COUNT(*)) |
23 | * |
24 | * @param string $expression value of the expression |
25 | * @param-taint $expression exec_sql |
26 | * @since 1.42 |
27 | */ |
28 | public function __construct( string $expression ) { |
29 | $this->expression = $expression; |
30 | } |
31 | |
32 | /** |
33 | * @internal to be used by rdbms library only |
34 | */ |
35 | public function toSql( DbQuoter $dbQuoter ): string { |
36 | return $this->expression; |
37 | } |
38 | |
39 | public function toGeneralizedSql(): string { |
40 | return $this->expression; |
41 | } |
42 | } |