[DDC-1719] When tablename or field name contains an hyphen it generates an error Created: 21/Mar/12  Updated: 25/Jun/12  Resolved: 25/Jun/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Minor
Reporter: Laurens Coudeville Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: None
Environment:

PHP 5.3



 Description   

In my database I have a table with '-' (hyphen) in the names of the tables and fields. But when mapping using annotations you get a mysql error because it generates a query that is not conform the mysql syntax. When using a hyphen in field or tablename (or others) you have to place it between quotes.

The name of the table can be resolved using quotes in the table name, in code it means:

@Table(name="directory-file") to @Table(name="`directory-file`"), you can't use this solution with the in the fields because the alias (AS in mysql syntax) also contains a '-' . Which results in a mysql error.

Failing code:

/**

  • @author Laurens
  • @Entity
  • @Table(name="directory-file")
    */
    class Directory_File {

/** @Id @Column(name="liddirectory-file",type="bigint") @GeneratedValue * */
protected $liddirectory_file;
}



 Comments   
Comment by Fabio B. Silva [ 25/Jun/12 ]

Fixed by : https://github.com/doctrine/doctrine2/commit/cb72219b118c158c9b5344c4b81ff2b1a9149ab0

Generated at Wed Aug 20 14:49:49 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.