Commit 2437390c authored by Steve Müller's avatar Steve Müller Committed by Marco Pivetta

fixes #2508: pass through index options when renaming index on table

parent 8a13144a
...@@ -253,10 +253,10 @@ class Table extends AbstractAsset ...@@ -253,10 +253,10 @@ class Table extends AbstractAsset
unset($this->_indexes[$oldIndexName]); unset($this->_indexes[$oldIndexName]);
if ($oldIndex->isUnique()) { if ($oldIndex->isUnique()) {
return $this->addUniqueIndex($oldIndex->getColumns(), $newIndexName); return $this->addUniqueIndex($oldIndex->getColumns(), $newIndexName, $oldIndex->getOptions());
} }
return $this->addIndex($oldIndex->getColumns(), $newIndexName, $oldIndex->getFlags()); return $this->addIndex($oldIndex->getColumns(), $newIndexName, $oldIndex->getFlags(), $oldIndex->getOptions());
} }
/** /**
......
...@@ -741,6 +741,34 @@ class TableTest extends \Doctrine\Tests\DbalTestCase ...@@ -741,6 +741,34 @@ class TableTest extends \Doctrine\Tests\DbalTestCase
$this->assertTrue($table->hasIndex('UNIQ_D87F7E0C76FF8CAA78240498')); $this->assertTrue($table->hasIndex('UNIQ_D87F7E0C76FF8CAA78240498'));
} }
/**
* @group DBAL-2508
*/
public function testKeepsIndexOptionsOnRenamingRegularIndex()
{
$table = new Table('foo');
$table->addColumn('id', 'integer');
$table->addIndex(array('id'), 'idx_bar', array(), array('where' => '1 = 1'));
$table->renameIndex('idx_bar', 'idx_baz');
$this->assertSame(array('where' => '1 = 1'), $table->getIndex('idx_baz')->getOptions());
}
/**
* @group DBAL-2508
*/
public function testKeepsIndexOptionsOnRenamingUniqueIndex()
{
$table = new Table('foo');
$table->addColumn('id', 'integer');
$table->addUniqueIndex(array('id'), 'idx_bar', array('where' => '1 = 1'));
$table->renameIndex('idx_bar', 'idx_baz');
$this->assertSame(array('where' => '1 = 1'), $table->getIndex('idx_baz')->getOptions());
}
/** /**
* @group DBAL-234 * @group DBAL-234
* @expectedException \Doctrine\DBAL\Schema\SchemaException * @expectedException \Doctrine\DBAL\Schema\SchemaException
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment