Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
TimestampType | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
getSQLDeclaration | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
42 | |||
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Wikimedia\Rdbms; |
4 | |
5 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
6 | use Doctrine\DBAL\Types\Type; |
7 | |
8 | /** |
9 | * Handling timestamp edge cases in mediawiki. |
10 | * https://www.mediawiki.org/wiki/Manual:Timestamp |
11 | */ |
12 | class TimestampType extends Type { |
13 | public const TIMESTAMP = 'mwtimestamp'; |
14 | |
15 | public function getSQLDeclaration( array $fieldDeclaration, AbstractPlatform $platform ) { |
16 | if ( $platform->getName() == 'mysql' ) { |
17 | // "infinite" (in expiry values has to be VARBINARY) |
18 | if ( isset( $fieldDeclaration['allowInfinite'] ) && $fieldDeclaration['allowInfinite'] ) { |
19 | return 'VARBINARY(14)'; |
20 | } |
21 | return 'BINARY(14)'; |
22 | } |
23 | |
24 | if ( $platform->getName() == 'sqlite' ) { |
25 | return 'BLOB'; |
26 | } |
27 | |
28 | if ( $platform->getName() == 'postgresql' ) { |
29 | return 'TIMESTAMPTZ'; |
30 | } |
31 | |
32 | return $platform->getDateTimeTzTypeDeclarationSQL( $fieldDeclaration ); |
33 | } |
34 | |
35 | public function getName() { |
36 | return self::TIMESTAMP; |
37 | } |
38 | } |