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 *
12 * @deprecated Support for SQLAnywhere will be removed in 3.0.
13 */
14class SQLAnywhere16Platform extends SQLAnywhere12Platform
15{
16    /**
17     * {@inheritdoc}
18     */
19    protected function getAdvancedIndexOptionsSQL(Index $index)
20    {
21        if ($index->hasFlag('with_nulls_distinct') && $index->hasFlag('with_nulls_not_distinct')) {
22            throw new UnexpectedValueException(
23                'An Index can either have a "with_nulls_distinct" or "with_nulls_not_distinct" flag but not both.'
24            );
25        }
26
27        if (! $index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_distinct')) {
28            return ' WITH NULLS DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
29        }
30
31        return parent::getAdvancedIndexOptionsSQL($index);
32    }
33
34    /**
35     * {@inheritdoc}
36     */
37    protected function getReservedKeywordsClass()
38    {
39        return Keywords\SQLAnywhere16Keywords::class;
40    }
41}
42