Completed
Pull Request — 2.11.x (#3956)
by David
14:33
created

SQLServer2008Platform   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

12 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeDoctrineTypeMappings() 0 7 1
A getDateTimeFormatString() 0 3 1
A getDateTimeTypeDeclarationSQL() 0 5 1
A getReservedKeywordsClass() 0 3 1
A getDateTimeTzTypeDeclarationSQL() 0 3 1
A getDateFormatString() 0 3 1
A getListTablesSQL() 0 5 1
A getDateTypeDeclarationSQL() 0 3 1
A getLikeWildcardCharacters() 0 3 1
A getDateTimeTzFormatString() 0 3 1
A getTimeTypeDeclarationSQL() 0 3 1
A getTimeFormatString() 0 3 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
 * @deprecated Use SQL Server 2012 or newer
12
 */
13
class SQLServer2008Platform extends SQLServer2005Platform
0 ignored issues
show
Deprecated Code introduced by
The class Doctrine\DBAL\Platforms\SQLServer2005Platform has been deprecated: Use SQL Server 2012 or newer ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

13
class SQLServer2008Platform extends /** @scrutinizer ignore-deprecated */ SQLServer2005Platform
Loading history...
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18 484
    public function getListTablesSQL()
19
    {
20
        // "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams
21
        // Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication
22 484
        return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name";
23
    }
24
25
    /**
26
     * {@inheritDoc}
27
     */
28 511
    public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
29
    {
30
        // 3 - microseconds precision length
31
        // http://msdn.microsoft.com/en-us/library/ms187819.aspx
32 511
        return 'DATETIME2(6)';
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38 457
    public function getDateTypeDeclarationSQL(array $fieldDeclaration)
39
    {
40 457
        return 'DATE';
41
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46 454
    public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
47
    {
48 454
        return 'TIME(0)';
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54 1882
    public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
55
    {
56 1882
        return 'DATETIMEOFFSET(6)';
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62 508
    public function getDateTimeFormatString()
63
    {
64 508
        return 'Y-m-d H:i:s.u';
65
    }
66
67
    /**
68
     * {@inheritDoc}
69
     */
70 239
    public function getDateTimeTzFormatString()
71
    {
72 239
        return 'Y-m-d H:i:s.u P';
73
    }
74
75
    /**
76
     * {@inheritDoc}
77
     */
78 236
    public function getDateFormatString()
79
    {
80 236
        return 'Y-m-d';
81
    }
82
83
    /**
84
     * {@inheritDoc}
85
     */
86 156
    public function getTimeFormatString()
87
    {
88 156
        return 'H:i:s';
89
    }
90
91
    /**
92
     * {@inheritDoc}
93
     *
94
     * Adding Datetime2 Type
95
     */
96 1822
    protected function initializeDoctrineTypeMappings()
97
    {
98 1822
        parent::initializeDoctrineTypeMappings();
99 1822
        $this->doctrineTypeMapping['datetime2']      = 'datetime';
100 1822
        $this->doctrineTypeMapping['date']           = 'date';
101 1822
        $this->doctrineTypeMapping['time']           = 'time';
102 1822
        $this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz';
103 1822
    }
104
105
    /**
106
     * {@inheritdoc}
107
     *
108
     * Returns Microsoft SQL Server 2008 specific keywords class
109
     */
110 1912
    protected function getReservedKeywordsClass()
111
    {
112 1912
        return Keywords\SQLServer2008Keywords::class;
113
    }
114
115 643
    protected function getLikeWildcardCharacters() : string
116
    {
117 643
        return parent::getLikeWildcardCharacters() . '[]^';
118
    }
119
}
120