Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2844

Doctrine\ORM\Query\QueryException raised when using Criteria object with more than one condition in repository.

    Details

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

      Description

      $userRepository = $em->getRepository ('User\Entity\User');
      $date = '2013-12-02';
      $dateFrom = new \DateTime ($date);
      $fateTo = (new \DateTime ($date))->add (new \DateInterval ('P1D');
      
      // OK
      $criteria = new \Doctrine\Common\Collections\Criteria ();
      $criteria
          ->where ($criteria->expr ()->gte ('signedIn', $dateFrom))
          ->andWhere ($criteria->expr ()->lt ('signedIn', $dateTo));
      var_dump ($userRepository->matching ($criteria));
      
      
      // NOT OK - Doctrine\ORM\Query\QueryException "Invalid parameter number: number of bound variables does not match number of tokens"
      $criteria = new \Doctrine\Common\Collections\Criteria ();
      $criteria
          ->where ($criteria->expr ()->gte ('user.signedIn', $dateFrom))
          ->andWhere ($criteria->expr ()->lt ('user.signedIn', $dateTo));
      var_dump ($userRepository->createQueryBuilder ('user')->addCriteria ($criteria)->getQuery ()->getResult ());
      
      
      // NOT OK - Doctrine\ORM\Query\QueryException "Invalid parameter number: number of bound variables does not match number of tokens"
      $criteria
          ->where ($criteria->expr ()->eq ('user.active', true))
          ->andWhere ($criteria->expr ()->eq ('user.active', true));
          //->orWhere ($criteria->expr ()->eq ('user.active', true));
      var_dump ($userRepository->createQueryBuilder ('user')->addCriteria ($criteria)->getQuery ()->getResult ());
      

        Activity

        Hide
        Matthias Althaus added a comment -

        Marco Pivetta, which tests do you mean exactly?

        Comparing the Doctrine\ORM\Query\QueryExpressionVisitor of the just released 2.4.3 and master the 2.4.x branch is still missing the fix.

        Show
        Matthias Althaus added a comment - Marco Pivetta , which tests do you mean exactly? Comparing the Doctrine\ORM\Query\QueryExpressionVisitor of the just released 2.4.3 and master the 2.4.x branch is still missing the fix.
        Hide
        Marco Pivetta added a comment -

        Matthias Althaus do the tests in this issue run on 2.4.x?

        Show
        Marco Pivetta added a comment - Matthias Althaus do the tests in this issue run on 2.4.x?
        Hide
        Matthias Althaus added a comment - - edited

        Stumbled upon this issue today. As this is fixed in master, but not in the 2.4.1 or 2.4.2 release... is this expected to be part of another 2.4.x or only 2.5 as it's just a "unsupported case" and no bug? Would be great if someone could updated the "Fix Version/s" as it's definitely not resolved in 2.4.1.

        Show
        Matthias Althaus added a comment - - edited Stumbled upon this issue today. As this is fixed in master, but not in the 2.4.1 or 2.4.2 release... is this expected to be part of another 2.4.x or only 2.5 as it's just a "unsupported case" and no bug? Would be great if someone could updated the "Fix Version/s" as it's definitely not resolved in 2.4.1.
        Show
        Marco Pivetta added a comment - Tests provided at https://github.com/doctrine/doctrine2/commit/ce914bef3fddebb4b54f4353f5daad6241802d9d
        Hide
        Doctrine Bot added a comment -

        A related Github Pull-Request [GH-875] was closed:
        https://github.com/doctrine/doctrine2/pull/875

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-875] was closed: https://github.com/doctrine/doctrine2/pull/875

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Yana Key
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: