1<?php
2
3namespace Doctrine\DBAL\Platforms;
4
5use Doctrine\DBAL\Schema\Index;
6use UnexpectedValueException;
7
8/**
9 * The SQLAnywhere16Platform provides the behavior, features and SQL dialect of the
10 * SAP Sybase SQL Anywhere 16 database platform.
11 */
12class SQLAnywhere16Platform extends SQLAnywhere12Platform
13{
14    /**
15     * {@inheritdoc}
16     */
17    protected function getAdvancedIndexOptionsSQL(Index $index)
18    {
19        if ($index->hasFlag('with_nulls_distinct') && $index->hasFlag('with_nulls_not_distinct')) {
20            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')) {
26            return ' WITH NULLS DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
27        }
28
29        return parent::getAdvancedIndexOptionsSQL($index);
30    }
31
32    /**
33     * {@inheritdoc}
34     */
35    protected function getReservedKeywordsClass()
36    {
37        return Keywords\SQLAnywhere16Keywords::class;
38    }
39}
40