Commit 5d6cd171 authored by Bart Visscher's avatar Bart Visscher

Fix sqlite autoincrement detection

parent 2790ee79
......@@ -220,7 +220,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
$autoincrementColumn = null;
$autoincrementCount = 0;
foreach ($tableColumns as $tableColumn) {
if ('1' == $tableColumn['pk']) {
if ('0' != $tableColumn['pk']) {
$autoincrementCount++;
if (null === $autoincrementColumn && 'integer' == strtolower($tableColumn['type'])) {
$autoincrementColumn = $tableColumn['name'];
......
......@@ -493,6 +493,18 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$inferredTable = $this->_sm->listTableDetails('test_autoincrement');
$this->assertTrue($inferredTable->hasColumn('id'));
$this->assertTrue($inferredTable->getColumn('id')->getAutoincrement());
$table = new \Doctrine\DBAL\Schema\Table('test_not_autoincrement');
$table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer');
$table->addColumn('other_id', 'integer');
$table->setPrimaryKey(array('id', 'other_id'));
$this->_sm->createTable($table);
$inferredTable = $this->_sm->listTableDetails('test_not_autoincrement');
$this->assertTrue($inferredTable->hasColumn('id'));
$this->assertFalse($inferredTable->getColumn('id')->getAutoincrement());
}
/**
......
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