MySQL57Platform.php 1.41 KB
Newer Older
1 2
<?php

Michael Moravec's avatar
Michael Moravec committed
3 4
declare(strict_types=1);

5 6 7
namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Schema\Index;
8
use Doctrine\DBAL\Schema\TableDiff;
9
use Doctrine\DBAL\Types\Types;
10 11

/**
12
 * Provides the behavior, features and SQL dialect of the MySQL 5.7 (5.7.9 GA) database platform.
13 14 15
 */
class MySQL57Platform extends MySqlPlatform
{
16
    public function hasNativeJsonType() : bool
17 18 19 20 21 22 23
    {
        return true;
    }

    /**
     * {@inheritdoc}
     */
24
    public function getJsonTypeDeclarationSQL(array $field) : string
25 26 27 28
    {
        return 'JSON';
    }

29 30 31
    /**
     * {@inheritdoc}
     */
32
    protected function getPreAlterTableRenameIndexForeignKeySQL(TableDiff $diff) : array
33
    {
34
        return [];
35 36 37 38 39
    }

    /**
     * {@inheritdoc}
     */
40
    protected function getPostAlterTableRenameIndexForeignKeySQL(TableDiff $diff) : array
41
    {
42
        return [];
43 44
    }

45 46 47
    /**
     * {@inheritdoc}
     */
48
    protected function getRenameIndexSQL(string $oldIndexName, Index $index, string $tableName) : array
49
    {
50
        return ['ALTER TABLE ' . $tableName . ' RENAME INDEX ' . $oldIndexName . ' TO ' . $index->getQuotedName($this)];
51 52
    }

53
    protected function getReservedKeywordsClass() : string
54
    {
55
        return Keywords\MySQL57Keywords::class;
56
    }
57

58
    protected function initializeDoctrineTypeMappings() : void
59 60 61
    {
        parent::initializeDoctrineTypeMappings();

62
        $this->doctrineTypeMapping['json'] = Types::JSON;
63
    }
64
}