Commit 3faa3a65 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #515 from bartv2/fix-pk-autoincrement-detection

Fix sqlite autoincrement detection
parents 79d04eed 36ad8544
......@@ -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'];
......
......@@ -496,6 +496,28 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertTrue($inferredTable->getColumn('id')->getAutoincrement());
}
/**
* @group DBAL-792
*/
public function testAutoincrementDetectionMulticolumns()
{
if (!$this->_sm->getDatabasePlatform()->supportsIdentityColumns()) {
$this->markTestSkipped('This test is only supported on platforms that have autoincrement');
}
$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());
}
/**
* @group DDC-887
*/
......
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