Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      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

        Activity

          People

          • Assignee:
            Fabio B. Silva
            Reporter:
            Marc Easen
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: