SQLAnywhere16Platform.php 1.1 KB
Newer Older
1 2 3 4 5
<?php

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Schema\Index;
6
use UnexpectedValueException;
7 8 9 10 11 12 13 14 15 16 17 18 19 20

/**
 * The SQLAnywhere16Platform provides the behavior, features and SQL dialect of the
 * SAP Sybase SQL Anywhere 16 database platform.
 */
class SQLAnywhere16Platform extends SQLAnywhere12Platform
{
    /**
     * {@inheritdoc}
     */
    protected function getAdvancedIndexOptionsSQL(Index $index)
    {
        if ($index->hasFlag('with_nulls_distinct') && $index->hasFlag('with_nulls_not_distinct')) {
            throw new UnexpectedValueException(
21
                'An Index can either have a "with_nulls_distinct" or "with_nulls_not_distinct" flag but not both.'
22 23 24
            );
        }

25
        if (! $index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_distinct')) {
Steve Müller's avatar
Steve Müller committed
26
            return ' WITH NULLS DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
27 28
        }

Steve Müller's avatar
Steve Müller committed
29
        return parent::getAdvancedIndexOptionsSQL($index);
30 31 32 33 34 35 36
    }

    /**
     * {@inheritdoc}
     */
    protected function getReservedKeywordsClass()
    {
37
        return Keywords\SQLAnywhere16Keywords::class;
38 39
    }
}