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

Closed
doctrinebot opened this Issue May 28, 2012 · 9 comments

1 participant

@doctrinebot

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

@doctrinebot

Comment created by @FabioBatSilva:

code format

@doctrinebot

Comment created by @FabioBatSilva:

Fixed by : cb72219

@doctrinebot

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

Comment created by easen:

See #390

@doctrinebot

Comment created by @FabioBatSilva:

Hi Marc,

Could you attach your entities or a test case please ?

Thanks

@doctrinebot

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

Comment created by @FabioBatSilva:

More details about the related problem : #390

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment