From 9d398afa569e2cc5dd4e35e8e7006b18afa14a32 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 28 Dec 2011 20:28:17 +0100 Subject: [PATCH] DDC-1360 - Bugfix in quoting mechanism inside ClassMetadataInfo --- .../ORM/Mapping/ClassMetadataInfo.php | 2 +- .../ORM/Functional/Ticket/DDC1360Test.php | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 50b2fdb4b..694b76d71 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1376,7 +1376,7 @@ class ClassMetadataInfo { 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']; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php new file mode 100644 index 000000000..f95f77eb4 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php @@ -0,0 +1,37 @@ +_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; +} +