Completed
Push — master ( c7757e...39cb21 )
by Luís
16s
created

Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php (1 issue)

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
use Doctrine\DBAL\Schema\Index;
23
use Doctrine\DBAL\Schema\Sequence;
24
25
/**
26
 * The SQLAnywhere12Platform provides the behavior, features and SQL dialect of the
27
 * SAP Sybase SQL Anywhere 12 database platform.
28
 *
29
 * @author Steve Müller <[email protected]>
30
 * @link   www.doctrine-project.org
31
 * @since  2.5
32
 */
33
class SQLAnywhere12Platform extends SQLAnywhere11Platform
34
{
35
    /**
36
     * {@inheritdoc}
37
     */
38 2 View Code Duplication
    public function getCreateSequenceSQL(Sequence $sequence)
39
    {
40 2
        return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) .
41 2
            ' INCREMENT BY ' . $sequence->getAllocationSize() .
42 2
            ' START WITH ' . $sequence->getInitialValue() .
43 2
            ' MINVALUE ' . $sequence->getInitialValue();
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 2
    public function getAlterSequenceSQL(Sequence $sequence)
50
    {
51 2
        return 'ALTER SEQUENCE ' . $sequence->getQuotedName($this) .
52 2
            ' INCREMENT BY ' . $sequence->getAllocationSize();
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 2
    public function getDateTimeTzFormatString()
59
    {
60 2
        return 'Y-m-d H:i:s.uP';
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66 2
    public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
67
    {
68 2
        return 'TIMESTAMP WITH TIME ZONE';
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74 2
    public function getDropSequenceSQL($sequence)
75
    {
76 2
        if ($sequence instanceof Sequence) {
77 2
            $sequence = $sequence->getQuotedName($this);
78
        }
79
80 2
        return 'DROP SEQUENCE ' . $sequence;
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86 2
    public function getListSequencesSQL($database)
87
    {
88 2
        return 'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE';
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94 2
    public function getSequenceNextValSQL($sequenceName)
95
    {
96 2
        return 'SELECT ' . $sequenceName . '.NEXTVAL';
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102 2
    public function supportsSequences()
103
    {
104 2
        return true;
105
    }
106
107
    /**
108
     * {@inheritdoc}
109
     */
110 16
    protected function getAdvancedIndexOptionsSQL(Index $index)
111
    {
112 16 View Code Duplication
        if ( ! $index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_not_distinct')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113 2
            return ' WITH NULLS NOT DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
114
        }
115
116 16
        return parent::getAdvancedIndexOptionsSQL($index);
117
    }
118
119
    /**
120
     * {@inheritdoc}
121
     */
122 53
    protected function getReservedKeywordsClass()
123
    {
124 53
        return Keywords\SQLAnywhere12Keywords::class;
125
    }
126
127
    /**
128
     * {@inheritDoc}
129
     */
130 12
    protected function initializeDoctrineTypeMappings()
131
    {
132 12
        parent::initializeDoctrineTypeMappings();
133 12
        $this->doctrineTypeMapping['timestamp with time zone'] = 'datetime';
134 12
    }
135
}
136