Commit da43b765 authored by Guilherme Blanco's avatar Guilherme Blanco

Merge pull request #528 from doctrine/hotfix/sqlite-auto-increment

Applying patch suggested by @guilhermeblanco for SQLite's auto-inc integer PKs
parents 594e326b 55236785
...@@ -289,6 +289,11 @@ class SqlitePlatform extends AbstractPlatform ...@@ -289,6 +289,11 @@ class SqlitePlatform extends AbstractPlatform
*/ */
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
{ {
// sqlite autoincrement is implicit for integer PKs, but not when the field is unsigned
if ( ! empty($columnDef['autoincrement'])) {
return '';
}
return ! empty($columnDef['unsigned']) ? ' UNSIGNED' : ''; return ! empty($columnDef['unsigned']) ? ' UNSIGNED' : '';
} }
......
...@@ -63,6 +63,14 @@ class SqlitePlatformTest extends AbstractPlatformTestCase ...@@ -63,6 +63,14 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
$this->assertTrue($this->_platform->prefersIdentityColumns()); $this->assertTrue($this->_platform->prefersIdentityColumns());
} }
public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers()
{
$this->assertSame(
'INTEGER',
$this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true))
);
}
/** /**
* @group DBAL-752 * @group DBAL-752
*/ */
......
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