diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index e5d74fb4337..51a59e68868 100644 --- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -293,7 +293,6 @@ protected function _getCreateTableSQL($name, array $columns, array $options = ar if (isset($options['primary']) && ! empty($options['primary'])) { $keyColumns = array_unique(array_values($options['primary'])); - $keyColumns = array_map(array($this, 'quoteIdentifier'), $keyColumns); $queryFields.= ', PRIMARY KEY('.implode(', ', $keyColumns).')'; } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index 0e50891e51a..6548cf8a62b 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -16,7 +16,7 @@ public function createPlatform() public function getGenerateTableSql() { - return 'CREATE TABLE test (id INTEGER NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY("id"))'; + return 'CREATE TABLE test (id INTEGER NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; } public function getGenerateTableWithMultiColumnUniqueIndexSql() @@ -131,4 +131,25 @@ public function testGetAlterTableSqlDispatchEvent() { $this->markTestSkipped('SQlite does not support ALTER Table.'); } + + /** + * @group DDC-1845 + */ + public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey() + { + $table = new \Doctrine\DBAL\Schema\Table('test'); + $table->addColumn('"like"', 'integer', array('notnull' => true, 'autoincrement' => true)); + $table->setPrimaryKey(array('"like"')); + + $createTableSQL = $this->_platform->getCreateTableSQL($table); + $this->assertEquals( + 'CREATE TABLE test ("like" INTEGER NOT NULL, PRIMARY KEY("like"))', + $createTableSQL[0] + ); + + $this->assertEquals( + 'ALTER TABLE test ADD PRIMARY KEY ("like")', + $this->_platform->getCreatePrimaryKeySQL($table->getIndex('primary'), 'test') + ); + } } \ No newline at end of file