Failed Conditions
Pull Request — master (#3184)
by Alexander
62:57
created

PostgreSQL100Platform::getReservedKeywordsClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 1
cts 1
cp 1
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Platforms;
6
7
use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords;
8
use Doctrine\DBAL\Schema\TableDiff;
9
10
/**
11
 * Provides the behavior, features and SQL dialect of the PostgreSQL 10.0 database platform.
12
 */
13
class PostgreSQL100Platform extends PostgreSQL94Platform
14
{
15
    /**
16
     * {@inheritdoc}
17 977
     */
18
    protected function getReservedKeywordsClass() : string
19 977
    {
20
        return PostgreSQL100Keywords::class;
21
    }
22 25
23
    public function getListSequencesSQL($database) : string
24
    {
25
        return "SELECT sequence_name AS relname,
26
                       sequence_schema AS schemaname,
27
                       minimum_value AS min_value, 
28
                       increment AS increment_by
29 25
                FROM   information_schema.sequences
30
                WHERE  sequence_catalog = " . $this->quoteStringLiteral($database) . "
31
                AND    sequence_schema NOT LIKE 'pg\_%'
32
                AND    sequence_schema != 'information_schema'";
33
    }
34
35
    protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
36
    {
37
        $tableName = $diff->getName($this)->getQuotedName($this);
38
39
        $sql = [];
40
        if ($this->supportsForeignKeyConstraints()) {
41
            foreach ($diff->removedForeignKeys as $foreignKey) {
42
                $sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName);
43
            }
44
            foreach ($diff->changedForeignKeys as $foreignKey) {
45
                $sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName);
46
            }
47
        }
48
49
        foreach ($diff->removedIndexes as $index) {
50
            $sql[] = $this->getDropIndexSQL($index, $tableName);
51
        }
52
        foreach ($diff->changedIndexes as $indexName => $index) {
53
            if ($index->isPrimary()) {
54
                $sql[] = $this->getDropConstraintSQL($indexName, $diff->fromTable);
55
                continue;
56
            }
57
            $sql[] = $this->getDropIndexSQL($index, $tableName);
58
        }
59
60
        return $sql;
61
    }
62
}
63