Passed
Push — tests-better-coverage ( 54ea4a...911183 )
by Michael
24:49
created

SQLServer2008Platform   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 12
dl 0
loc 105
ccs 29
cts 29
cp 1
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeDoctrineTypeMappings() 0 7 1
A getReservedKeywordsClass() 0 3 1
A getDateTimeTzTypeDeclarationSQL() 0 3 1
A getLikeWildcardCharacters() 0 3 1
A getDateTimeFormatString() 0 3 1
A getDateTimeTypeDeclarationSQL() 0 5 1
A getDateFormatString() 0 3 1
A getTimeFormatString() 0 3 1
A getListTablesSQL() 0 5 1
A getDateTypeDeclarationSQL() 0 3 1
A getDateTimeTzFormatString() 0 3 1
A getTimeTypeDeclarationSQL() 0 3 1
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Doctrine\DBAL\Platforms;
21
22
/**
23
 * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2008 version.
24
 *
25
 * Differences to SQL Server 2005 and before are that a new DATETIME2 type was
26
 * introduced that has a higher precision.
27
 */
28
class SQLServer2008Platform extends SQLServer2005Platform
29
{
30
    /**
31
     * {@inheritDoc}
32
     */
33 130
    public function getListTablesSQL()
34
    {
35
        // "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams
36
        // Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication
37 130
        return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
38
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43 40
    public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
44
    {
45
        // 3 - microseconds precision length
46
        // http://msdn.microsoft.com/en-us/library/ms187819.aspx
47 40
        return 'DATETIME2(6)';
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     */
53 38
    public function getDateTypeDeclarationSQL(array $fieldDeclaration)
54
    {
55 38
        return 'DATE';
56
    }
57
58
    /**
59
     * {@inheritDoc}
60
     */
61 38
    public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
62
    {
63 38
        return 'TIME(0)';
64
    }
65
66
    /**
67
     * {@inheritDoc}
68
     */
69 47
    public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
70
    {
71 47
        return 'DATETIMEOFFSET(6)';
72
    }
73
74
    /**
75
     * {@inheritDoc}
76
     */
77 22
    public function getDateTimeFormatString()
78
    {
79 22
        return 'Y-m-d H:i:s.u';
80
    }
81
82
    /**
83
     * {@inheritDoc}
84
     */
85 2
    public function getDateTimeTzFormatString()
86
    {
87 2
        return 'Y-m-d H:i:s.u P';
88
    }
89
90
    /**
91
     * {@inheritDoc}
92
     */
93 2
    public function getDateFormatString()
94
    {
95 2
        return 'Y-m-d';
96
    }
97
98
    /**
99
     * {@inheritDoc}
100
     */
101 2
    public function getTimeFormatString()
102
    {
103 2
        return 'H:i:s';
104
    }
105
106
    /**
107
     * {@inheritDoc}
108
     *
109
     * Adding Datetime2 Type
110
     */
111 172
    protected function initializeDoctrineTypeMappings()
112
    {
113 172
        parent::initializeDoctrineTypeMappings();
114 172
        $this->doctrineTypeMapping['datetime2'] = 'datetime';
115 172
        $this->doctrineTypeMapping['date'] = 'date';
116 172
        $this->doctrineTypeMapping['time'] = 'time';
117 172
        $this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz';
118 172
    }
119
120
    /**
121
     * {@inheritdoc}
122
     *
123
     * Returns Microsoft SQL Server 2008 specific keywords class
124
     */
125 1054
    protected function getReservedKeywordsClass()
126
    {
127 1054
        return Keywords\SQLServer2008Keywords::class;
128
    }
129
130 36
    protected function getLikeWildcardCharacters() : string
131
    {
132 36
        return parent::getLikeWildcardCharacters() . '[]^';
133
    }
134
}
135