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

        Marc Easen created issue -
        Marc Easen made changes -
        Field Original Value New Value
        Affects Version/s 2.1.6 [ 10182 ]
        Affects Version/s 2.0-ALPHA3 [ 10029 ]
        Description Join columns can't be quoted like columns using name="`quoted`". Using annotation driver.

        Not sure where this would occur. AnnotationDriver? ORM? DBAL?
        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

        Attachment quoted_joins_fix.diff [ 11194 ]
        Fix Version/s 2.0-BETA1 [ 10030 ]
        Hide
        Fabio B. Silva added a comment -

        code format

        Show
        Fabio B. Silva added a comment - code format
        Fabio B. Silva made changes -
        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

        Join columns can't be quoted like columns using name="`quoted`". Using annotation driver.

        {code}

        /**
         * @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();
        }
        {code}

        Result: Invalid parameter number: number of bound variables does not match number of tokens
        Fabio B. Silva made changes -
        Assignee Roman S. Borschel [ romanb ] Fabio B. Silva [ fabio.bat.silva ]
        Show
        Fabio B. Silva added a comment - Fixed by : https://github.com/doctrine/doctrine2/commit/cb72219b118c158c9b5344c4b81ff2b1a9149ab0
        Fabio B. Silva made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.3 [ 10185 ]
        Resolution Fixed [ 1 ]
        Hide
        Marc Easen added a comment -

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

        Show
        Marc Easen added a comment - 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 (?, ?)
        Marc Easen made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Show
        Marc Easen added a comment - See https://github.com/doctrine/doctrine2/pull/390
        Hide
        Fabio B. Silva added a comment -

        Hi Marc,

        Could you attach your entities or a test case please ?

        Thanks

        Show
        Fabio B. Silva added a comment - Hi Marc, Could you attach your entities or a test case please ? Thanks
        Hide
        Fabio B. Silva added a comment -

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

        Show
        Fabio B. Silva added a comment - 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..
        Benjamin Eberlei made changes -
        Workflow jira [ 13737 ] jira-feedback [ 14107 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14107 ] jira-feedback2 [ 15971 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15971 ] jira-feedback3 [ 18224 ]
        Hide
        Fabio B. Silva added a comment -

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

        Show
        Fabio B. Silva added a comment - More details about the related problem : https://github.com/doctrine/doctrine2/pull/390
        Fabio B. Silva made changes -
        Status Reopened [ 4 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1843, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

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

            Dates

            • Created:
              Updated:
              Resolved: