Commit cf93b0dc authored by Benjamin Eberlei's avatar Benjamin Eberlei

Quote identifier if its a keyword in the given platform

parent 576eae09
......@@ -71,7 +71,7 @@ abstract class AbstractAsset
/**
* Trim quotes from the identifier.
*
*
* @param string $identifier
* @return string
*/
......@@ -82,7 +82,7 @@ abstract class AbstractAsset
/**
* Return name of this schema asset.
*
*
* @return string
*/
public function getName()
......@@ -99,7 +99,8 @@ abstract class AbstractAsset
*/
public function getQuotedName(AbstractPlatform $platform)
{
return ($this->_quoted) ? $platform->quoteIdentifier($this->_name) : $this->_name;
$keywords = $platform->getReservedKeywordsList();
return ($this->_quoted || $keywords->isKeyword($this->_name)) ? $platform->quoteIdentifier($this->_name) : $this->_name;
}
/**
......
......@@ -7,7 +7,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
require_once __DIR__ . '/../../../TestInit.php';
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
/**
......@@ -116,7 +116,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$column->setAutoincrement(true);
$nestedSchemaTable->setPrimaryKey(array('id'));
$nestedSchemaTable->addUnnamedForeignKeyConstraint($nestedRelatedTable, array('id'), array('id'));
$this->_sm->createTable($nestedRelatedTable);
$this->_sm->createTable($nestedSchemaTable);
......@@ -149,7 +149,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertEquals(
array(
"CREATE TABLE dbal91_something (id INT NOT NULL, table INT DEFAULT NULL, PRIMARY KEY(id))",
"CREATE TABLE dbal91_something (id INT NOT NULL, \"table\" INT DEFAULT NULL, PRIMARY KEY(id))",
"CREATE INDEX IDX_A9401304ECA7352B ON dbal91_something (\"table\")",
),
$this->_conn->getDatabasePlatform()->getCreateTableSQL($table)
......
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