public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() { $this->assertEquals('CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) WITH NULLS NOT DISTINCT FOR OLAP WORKLOAD', $this->_platform->getCreateIndexSQL(new Index('fooindex', array('a', 'b'), true, false, array('virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload')), 'footable')); $this->assertEquals('CREATE VIRTUAL CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD', $this->_platform->getCreateIndexSQL(new Index('fooindex', array('a', 'b'), false, false, array('virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload')), 'footable')); // WITH NULLS NOT DISTINCT clause not available on primary indexes. $this->assertEquals('ALTER TABLE footable ADD PRIMARY KEY (a, b)', $this->_platform->getCreateIndexSQL(new Index('fooindex', array('a', 'b'), false, true, array('with_nulls_not_distinct')), 'footable')); // WITH NULLS NOT DISTINCT clause not available on non-unique indexes. $this->assertEquals('CREATE INDEX fooindex ON footable (a, b)', $this->_platform->getCreateIndexSQL(new Index('fooindex', array('a', 'b'), false, false, array('with_nulls_not_distinct')), 'footable')); }
/** * {@inheritdoc} */ protected function getAdvancedIndexOptionsSQL(Index $index) { if ($index->hasFlag('with_nulls_distinct') && $index->hasFlag('with_nulls_not_distinct')) { throw new UnexpectedValueException('An Index can either have a "with_nulls_distinct" or "with_nulls_not_distinct" flag but not both.'); } if (!$index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_distinct')) { return ' WITH NULLS DISTINCT' . parent::getAdvancedIndexOptionsSQL($index); } return parent::getAdvancedIndexOptionsSQL($index); }