[DDC-832] Not quoted class name when updating entity Created: 07/Oct/10  Updated: 30/Oct/10  Resolved: 30/Oct/10

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.0-BETA4
Fix Version/s: 2.0-RC1
Security Level: All

Type: Bug Priority: Critical
Reporter: Paul Fariello Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

postgresql 8.4 php 5.3.2


Issue Links:
Reference
relates to DBAL-57 Handling of Quoted Elements Open

 Description   

When trying to update an entity which have a reserved name. Doctrine doesn't quoted its name.

On Doctrine\ORM\Persisters\BasicEntityPersister, _updateTable, $tableName is directly used to create the sql. We may use $this->_class->getQuotedTableName($this->_platform) instead ?

I'm going to propose a merge for that on github.



 Comments   
Comment by Paul Fariello [ 08/Oct/10 ]

Here is a test case

Mapping
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <entity name="Like" table="`like`">
        <id name="id" type="integer" column="id">
            <generator strategy="SEQUENCE"/>
            <sequence-generator sequence-name="like_id_seq" allocation-size="1" initial-value="1"/>
        </id>

        <field name="value" column="value" type="string" />
    </entity>
</doctrine-mapping>
SQL
CREATE TABLE "like"
(
  id serial NOT NULL,
  "value" character varying,
  CONSTRAINT like_pkey PRIMARY KEY (id)
);
Class
class Like {

  private $id;
  public  $value;
}
Test case
$entity = new Like();
$entity->value = 'toto';

$doctrineEntityManager->persist($entity);
$doctrineEntityManager->flush();

$entity->value = 'tata';
$doctrineEntityManager->flush();
Comment by Benjamin Eberlei [ 30/Oct/10 ]

This issue partly depends on DBAL-57 (otherwise the testsuite keeps failing)

Comment by Benjamin Eberlei [ 30/Oct/10 ]

There is really no simple fix for this issue, your proposed one breaks joined table inheritance.

Comment by Benjamin Eberlei [ 30/Oct/10 ]

Found a way! fixed.

Generated at Tue Oct 21 08:54:49 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.