Ignore SQLite indexes with reserved names

These are internal, automatically-created and shouldn't be considered part of
the schema. They cannot be recreated because of their reserved names.
parent ced12abf
...@@ -93,6 +93,8 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -93,6 +93,8 @@ class SqliteSchemaManager extends AbstractSchemaManager
// fetch regular indexes // fetch regular indexes
foreach($tableIndexes AS $tableIndex) { foreach($tableIndexes AS $tableIndex) {
// Ignore indexes with reserved names, e.g. autoindexes
if (strpos($tableIndex['name'], 'sqlite_') !== 0) {
$keyName = $tableIndex['name']; $keyName = $tableIndex['name'];
$idx = array(); $idx = array();
$idx['key_name'] = $keyName; $idx['key_name'] = $keyName;
...@@ -107,6 +109,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -107,6 +109,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
$indexBuffer[] = $idx; $indexBuffer[] = $idx;
} }
} }
}
return parent::_getPortableTableIndexesList($indexBuffer, $tableName); return parent::_getPortableTableIndexesList($indexBuffer, $tableName);
} }
......
...@@ -199,7 +199,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -199,7 +199,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals(3, count($tableIndexes)); $this->assertEquals(3, count($tableIndexes));
$this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.'); $this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.');
$this->assertEquals(array('id'), array_map('strtolower', $tableIndexes['primary']->getColumns())); $this->assertEquals(array('id', 'other_id'), array_map('strtolower', $tableIndexes['primary']->getColumns()));
$this->assertTrue($tableIndexes['primary']->isUnique()); $this->assertTrue($tableIndexes['primary']->isUnique());
$this->assertTrue($tableIndexes['primary']->isPrimary()); $this->assertTrue($tableIndexes['primary']->isPrimary());
...@@ -505,7 +505,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -505,7 +505,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, $options); $table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, $options);
$table->setSchemaConfig($this->_sm->createSchemaConfig()); $table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer', array('notnull' => true)); $table->addColumn('id', 'integer', array('notnull' => true));
$table->setPrimaryKey(array('id')); $table->addColumn('other_id', 'integer', array('notnull' => true));
$table->setPrimaryKey(array('id', 'other_id'));
$table->addColumn('test', 'string', array('length' => 255)); $table->addColumn('test', 'string', array('length' => 255));
$table->addColumn('foreign_key_test', 'integer'); $table->addColumn('foreign_key_test', 'integer');
return $table; return $table;
......
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