DDC-1843: CLONE -Join columns can't be quoted #2322

Closed
opened 2026-01-22 13:48:24 +01:00 by admin · 9 comments
Owner

Originally created by @doctrinebot on GitHub (May 28, 2012).

Jira issue originally created by user easen:

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

Originally created by @doctrinebot on GitHub (May 28, 2012). Jira issue originally created by user easen: 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
admin added the Bug label 2026-01-22 13:48:24 +01:00
admin closed this issue 2026-01-22 13:48:25 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 28, 2012):

Comment created by @FabioBatSilva:

code format

@doctrinebot commented on GitHub (May 28, 2012): Comment created by @FabioBatSilva: code format
Author
Owner

@doctrinebot commented on GitHub (Jun 25, 2012):

Comment created by @FabioBatSilva:

Fixed by : cb72219b11

@doctrinebot commented on GitHub (Jun 25, 2012): Comment created by @FabioBatSilva: Fixed by : https://github.com/doctrine/doctrine2/commit/cb72219b118c158c9b5344c4b81ff2b1a9149ab0
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2012):

Comment created by easen:

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 (?, ?)

@doctrinebot commented on GitHub (Jul 5, 2012): Comment created by easen: 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 (?, ?)
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2012):

Comment created by easen:

See https://github.com/doctrine/doctrine2/pull/390

@doctrinebot commented on GitHub (Jul 5, 2012): Comment created by easen: See https://github.com/doctrine/doctrine2/pull/390
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2012):

Comment created by @FabioBatSilva:

Hi Marc,

Could you attach your entities or a test case please ?

Thanks

@doctrinebot commented on GitHub (Jul 5, 2012): Comment created by @FabioBatSilva: Hi Marc, Could you attach your entities or a test case please ? Thanks
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2012):

Comment created by @FabioBatSilva:

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..

@doctrinebot commented on GitHub (Jul 5, 2012): Comment created by @FabioBatSilva: 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..
Author
Owner

@doctrinebot commented on GitHub (Aug 15, 2012):

Comment created by @FabioBatSilva:

More details about the related problem : https://github.com/doctrine/doctrine2/pull/390

@doctrinebot commented on GitHub (Aug 15, 2012): Comment created by @FabioBatSilva: More details about the related problem : https://github.com/doctrine/doctrine2/pull/390
Author
Owner

@doctrinebot commented on GitHub (Aug 15, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Aug 15, 2012): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/27d016562e44fbc5fc6d

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/27d016562e44fbc5fc6d - [11194_quoted_joins_fix.diff](https://gist.github.com/27d016562e44fbc5fc6d#file-11194_quoted_joins_fix-diff)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2322