/** * {@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); }
/** * @param string $table * @param \Doctrine\DBAL\Schema\Index $index * @return array */ protected function indexToArray($table, $index) { if ($index->isPrimary()) { $type = 'primary'; } elseif ($index->isUnique()) { $type = 'unique'; } else { $type = 'index'; } $array = ['type' => $type, 'name' => null, 'columns' => $index->getColumns()]; if (!$this->isDefaultIndexName($table, $index->getName(), $type, $index->getColumns())) { $array['name'] = $index->getName(); } return $array; }
/** * @param string $table * @param \Doctrine\DBAL\Schema\Index $index * @return array */ protected function indexToArray($table, $index) { if ($index->isPrimary()) { $type = 'primary'; } elseif ($index->isUnique()) { $type = 'unique'; } else { $type = 'index'; } $array = ['type' => $type, 'name' => null, 'columns' => $index->getColumns()]; if (!$this->ignoreIndexNames and !$this->isDefaultIndexName($table, $index->getName(), $type, $index->getColumns())) { // Sent Index name to exclude spaces $array['name'] = str_replace(' ', '', $index->getName()); } return $array; }
/** * {@inheritdoc} */ protected function getCreateIndexSQLFlags(Index $index) { $type = ''; if ($index->hasFlag('virtual')) { $type .= 'VIRTUAL '; } if ($index->isUnique()) { $type .= 'UNIQUE '; } if ($index->hasFlag('clustered')) { $type .= 'CLUSTERED '; } return $type; }
/** * {@inheritDoc} */ protected function getCreateIndexSQLFlags(Index $index) { $type = ''; if ($index->isUnique()) { $type .= 'UNIQUE '; } elseif ($index->hasFlag('fulltext')) { $type .= 'FULLTEXT '; } elseif ($index->hasFlag('spatial')) { $type .= 'SPATIAL '; } return $type; }
/** * Detect if the other index is a non-unique, non primary index that can be overwritten by this one. * * @param Index $other * @return bool */ public function overrules(Index $other) { if ($other->isPrimary()) { return false; } else { if ($this->isSimpleIndex() && $other->isUnique()) { return false; } } if ($this->spansColumns($other->getColumns()) && ($this->isPrimary() || $this->isUnique())) { return true; } return false; }
/** * {@inheritDoc} */ protected function getCreateIndexSQLFlags(Index $index) { $type = ''; if ($index->isUnique()) { $type .= 'UNIQUE '; } if ($index->hasFlag('clustered')) { $type .= 'CLUSTERED '; } elseif ($index->hasFlag('nonclustered')) { $type .= 'NONCLUSTERED '; } return $type; }
/** * Obtain DBMS specific SQL code portion needed to set an index * declaration to be used in statements like CREATE TABLE. * * @param string $name name of the index * @param Index $index index definition * @return string DBMS specific SQL code portion needed to set an index */ public function getIndexDeclarationSQL($name, Index $index) { $type = ''; if ($index->isUnique()) { $type = 'UNIQUE '; } if (count($index->getColumns()) == 0) { throw \InvalidArgumentException("Incomplete definition. 'columns' required."); } return $type . 'INDEX ' . $name . ' (' . $this->getIndexFieldDeclarationListSQL($index->getColumns()) . ')'; }
/** * Adds additional flags for index generation. * * @param \Doctrine\DBAL\Schema\Index $index * * @return string */ protected function getCreateIndexSQLFlags(Index $index) { return $index->isUnique() ? 'UNIQUE ' : ''; }
/** * {@inheritdoc} */ protected function getAdvancedIndexOptionsSQL(Index $index) { if (!$index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_not_distinct')) { return ' WITH NULLS NOT DISTINCT' . parent::getAdvancedIndexOptionsSQL($index); } return parent::getAdvancedIndexOptionsSQL($index); }
/** * @param Index $index * @param \SimpleXMLElement $xml */ private static function saveIndex($index, $xml) { $xml->addChild('name', $index->getName()); if ($index->isPrimary()) { $xml->addChild('primary', 'true'); } elseif ($index->isUnique()) { $xml->addChild('unique', 'true'); } foreach ($index->getColumns() as $column) { $field = $xml->addChild('field'); $field->addChild('name', $column); $field->addChild('sorting', 'ascending'); } }
/** * Creates a index replacement, which has quoted names. * * @param Index $index * * @return Index */ private function createIndexReplacement(Index $index) { return new Index($this->platform->quoteIdentifier($index->getName()), $this->quoteIdentifiers($index->getColumns()), $index->isUnique(), $index->isPrimary(), $index->getFlags(), $index->getOptions()); }
/** * Accept an index on in a table * * @param Table $table a table object * @param Index $index a column object * * @return void */ public function acceptIndex(Table $table, Index $index) { $this->schemaArray['tables'][$table->getName()]['indexes'][$index->getName()] = array('name' => $index->getName(), 'columns' => $index->getColumns(), 'unique' => $index->isUnique(), 'primary' => $index->isPrimary()); }