Failed Conditions
Push — master ( 070684...f9e00b )
by Sergei
64:19 queued 60:49
created

SQLServer2008Platform::getTimeFormatString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Doctrine\DBAL\Platforms;
4
5
/**
6
 * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2008 version.
7
 *
8
 * Differences to SQL Server 2005 and before are that a new DATETIME2 type was
9
 * introduced that has a higher precision.
10
 */
11
class SQLServer2008Platform extends SQLServer2005Platform
12
{
13
    /**
14
     * {@inheritDoc}
15
     */
16 319
    public function getListTablesSQL()
17
    {
18
        // "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams
19
        // Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication
20 319
        return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
21
    }
22
23
    /**
24
     * {@inheritDoc}
25
     */
26 337
    public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
27
    {
28
        // 3 - microseconds precision length
29
        // http://msdn.microsoft.com/en-us/library/ms187819.aspx
30 337
        return 'DATETIME2(6)';
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36 301
    public function getDateTypeDeclarationSQL(array $fieldDeclaration)
37
    {
38 301
        return 'DATE';
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44 299
    public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
45
    {
46 299
        return 'TIME(0)';
47
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52 1864
    public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
53
    {
54 1864
        return 'DATETIMEOFFSET(6)';
55
    }
56
57
    /**
58
     * {@inheritDoc}
59
     */
60 335
    public function getDateTimeFormatString()
61
    {
62 335
        return 'Y-m-d H:i:s.u';
63
    }
64
65
    /**
66
     * {@inheritDoc}
67
     */
68 159
    public function getDateTimeTzFormatString()
69
    {
70 159
        return 'Y-m-d H:i:s.u P';
71
    }
72
73
    /**
74
     * {@inheritDoc}
75
     */
76 157
    public function getDateFormatString()
77
    {
78 157
        return 'Y-m-d';
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84 78
    public function getTimeFormatString()
85
    {
86 78
        return 'H:i:s';
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     *
92
     * Adding Datetime2 Type
93
     */
94 1741
    protected function initializeDoctrineTypeMappings()
95
    {
96 1741
        parent::initializeDoctrineTypeMappings();
97 1741
        $this->doctrineTypeMapping['datetime2']      = 'datetime';
98 1741
        $this->doctrineTypeMapping['date']           = 'date';
99 1741
        $this->doctrineTypeMapping['time']           = 'time';
100 1741
        $this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz';
101 1741
    }
102
103
    /**
104
     * {@inheritdoc}
105
     *
106
     * Returns Microsoft SQL Server 2008 specific keywords class
107
     */
108 1974
    protected function getReservedKeywordsClass()
109
    {
110 1974
        return Keywords\SQLServer2008Keywords::class;
111
    }
112
113 486
    protected function getLikeWildcardCharacters() : string
114
    {
115 486
        return parent::getLikeWildcardCharacters() . '[]^';
116
    }
117
}
118