PostgreSQL92Platform.php 1.39 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Platforms;

5
use Doctrine\DBAL\Types\Types;
6
use function sprintf;
7

8 9 10
/**
 * Provides the behavior, features and SQL dialect of the PostgreSQL 9.2 database platform.
 */
11
class PostgreSQL92Platform extends PostgreSQL91Platform
12 13 14 15 16 17 18 19 20
{
    /**
     * {@inheritdoc}
     */
    public function getJsonTypeDeclarationSQL(array $field)
    {
        return 'JSON';
    }

21 22 23 24 25
    /**
     * {@inheritdoc}
     */
    public function getSmallIntTypeDeclarationSQL(array $field)
    {
26
        if (! empty($field['autoincrement'])) {
27 28 29 30 31 32
            return 'SMALLSERIAL';
        }

        return parent::getSmallIntTypeDeclarationSQL($field);
    }

33 34 35 36 37 38 39 40 41 42 43 44 45
    /**
     * {@inheritdoc}
     */
    public function hasNativeJsonType()
    {
        return true;
    }

    /**
     * {@inheritdoc}
     */
    protected function getReservedKeywordsClass()
    {
46
        return Keywords\PostgreSQL92Keywords::class;
47 48 49 50 51 52 53 54
    }

    /**
     * {@inheritdoc}
     */
    protected function initializeDoctrineTypeMappings()
    {
        parent::initializeDoctrineTypeMappings();
55

56
        $this->doctrineTypeMapping['json'] = Types::JSON;
57
    }
58 59 60 61 62 63

    /**
     * {@inheritdoc}
     */
    public function getCloseActiveDatabaseConnectionsSQL($database)
    {
64 65 66 67
        return sprintf(
            'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = %s',
            $this->quoteStringLiteral($database)
        );
68
    }
69
}