Skip to content

Commit

Permalink
Merge pull request #515 from bartv2/fix-pk-autoincrement-detection
Browse files Browse the repository at this point in the history
Fix sqlite autoincrement detection
  • Loading branch information
beberlei committed Feb 8, 2014
2 parents 79d04ee + 36ad854 commit 3faa3a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected function _getPortableTableColumnList($table, $database, $tableColumns)
$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'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,28 @@ public function testAutoincrementDetection()
$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
*/
Expand Down

0 comments on commit 3faa3a6

Please sign in to comment.