Skip to content

Commit

Permalink
DDC-1360 - Bugfix in quoting mechanism inside ClassMetadataInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Dec 28, 2011
1 parent e5cf1da commit 9d398af
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Expand Up @@ -1376,7 +1376,7 @@ public function setPrimaryTable(array $table)
{
if (isset($table['name'])) {
if ($table['name'][0] == '`') {
$this->table['name'] = trim($table['name'], '`');
$this->table['name'] = str_replace("`", "", $table['name']);
$this->table['quoted'] = true;
} else {
$this->table['name'] = $table['name'];
Expand Down
37 changes: 37 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php
@@ -0,0 +1,37 @@
<?php

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\Tests\OrmFunctionalTestCase;

/**
* @group DDC-1360
*/
class DDC1360Test extends OrmFunctionalTestCase
{
public function testSchemaDoubleQuotedCreate()
{
if ($this->_em->getConnection()->getDatabasePlatform()->getName() != "postgresql") {
$this->markTestSkipped("PostgreSQL only test.");
}

$sql = $this->_schemaTool->getCreateSchemaSQL(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1360DoubleQuote')
));

$this->assertEquals(array(
'CREATE TABLE "user"."user" (id INT NOT NULL, PRIMARY KEY(id))',
'CREATE SEQUENCE "user".user_id_seq INCREMENT BY 1 MINVALUE 1 START 1',
), $sql);
}
}

/**
* @Entity @Table(name="`user`.`user`")
*/
class DDC1360DoubleQuote
{
/** @Id @GeneratedValue @Column(type="integer") */
public $id;
}

0 comments on commit 9d398af

Please sign in to comment.