[DDC-1843] CLONE -Join columns can't be quoted Created: 28/May/12 Updated: 15/Aug/12 Resolved: 15/Aug/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1.6 |
| Fix Version/s: | 2.3 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Marc Easen | Assignee: | Fabio B. Silva |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Join columns can't be quoted like columns using name="`quoted`". Using annotation driver. /** * @ORM\Table( * name="`category`", * indexes={ * @ORM\Index( * name="fk_category_parentId", * columns={"parentId"} * ) * }, * uniqueConstraints={ * @ORM\UniqueConstraint( * name="uq_category_nameParentId", * columns={"name", "parentId"} * ) * } * ) */ class Category { /** * @ORM\Id * @ORM\Column(type="smallint", name="`id`") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\Column(type="smallint", name="`parentId`", nullable=true) */ protected $parentId; /** * @ORM\Column(type="string", length=50, name="`name`") */ protected $name; /** * @ORM\ManyToOne(targetEntity="Category", inversedBy="categories") * @ORM\JoinColumn(name="parentId", referencedColumnName="id", onDelete="CASCADE", onUpdate="NO ACTION") */ protected $category; } ... public function load(ObjectManager $manager) { $parent = new Category(); $parent->setName('parent'); $manager->persist($parent); $manager->flush(); $child = new Category(); $child->setName('parent'); $child->setParentId($parent->getId()); $child->setCategory($parent); $manager->persist($child); $manager->flush(); } Result: Invalid parameter number: number of bound variables does not match number of tokens |
| Comments |
| Comment by Fabio B. Silva [ 28/May/12 ] |
|
code format |
| Comment by Fabio B. Silva [ 25/Jun/12 ] |
|
Fixed by : https://github.com/doctrine/doctrine2/commit/cb72219b118c158c9b5344c4b81ff2b1a9149ab0 |
| Comment by Marc Easen [ 05/Jul/12 ] |
|
When inserting into an entity which has quoted columns and unquoted JoinColumn the generated SQL includes the correct number of parameters but the incorrect columns names and bind parameters: INSERT INTO `table` (`c1`, c1) VALUES (?, ?) |
| Comment by Marc Easen [ 05/Jul/12 ] |
| Comment by Fabio B. Silva [ 05/Jul/12 ] |
|
Hi Marc, Could you attach your entities or a test case please ? Thanks |
| Comment by Fabio B. Silva [ 05/Jul/12 ] |
|
Marc, why do you need to quoted columns and unquoted join column ? For sure duplicated columns is a problem, but your use case does not make sense for me.. |
| Comment by Fabio B. Silva [ 15/Aug/12 ] |
|
More details about the related problem : https://github.com/doctrine/doctrine2/pull/390 |