Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[SQLITE] Remove primary key auto quote #158

Merged
merged 2 commits into from

3 participants

@FabioBatSilva

Hi guys.

This patch remove the primary key auto quote in sqlite
I think this is a wrong behavior, other drivers does not do the auto quote.

Cheers

@travisbot

This pull request passes (merged 93bacd3 into e537745).

@guilhermeblanco guilhermeblanco merged commit baf30ae into doctrine:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  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).')';
}
View
23 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')
+ );
+ }
}
Something went wrong with that request. Please try again.