Commit 33555d36 authored by Martin Hasoň's avatar Martin Hasoň

Added detection of autoincrement column to Sqlite schema

parent 38bd0693
...@@ -197,6 +197,31 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -197,6 +197,31 @@ class SqliteSchemaManager extends AbstractSchemaManager
); );
} }
protected function _getPortableTableColumnList($table, $database, $tableColumns)
{
$list = parent::_getPortableTableColumnList($table, $database, $tableColumns);
$autoincrementColumn = null;
$autoincrementCount = 0;
foreach ($tableColumns as $tableColumn) {
if ('1' == $tableColumn['pk']) {
$autoincrementCount++;
if (null === $autoincrementColumn && 'integer' == strtolower($tableColumn['type'])) {
$autoincrementColumn = $tableColumn['name'];
}
}
}
if (1 == $autoincrementCount && null !== $autoincrementColumn) {
foreach ($list as $column) {
if ($autoincrementColumn == $column->getName()) {
$column->setAutoincrement(true);
}
}
}
return $list;
}
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition($tableColumn)
{ {
$e = explode('(', $tableColumn['type']); $e = explode('(', $tableColumn['type']);
......
...@@ -38,11 +38,11 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -38,11 +38,11 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertNotContains('oldname', $tables); $this->assertNotContains('oldname', $tables);
} }
public function testAutoincrementDetection() public function createListTableColumns()
{ {
$this->markTestSkipped( $table = parent::createListTableColumns();
'There is currently no reliable way to determine whether an SQLite column is marked as ' $table->getColumn('id')->setAutoincrement(true);
. 'auto-increment. So, while it does support a single identity column, we cannot with '
. 'certainty determine which it is.'); 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