Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2285

Repeating the same query with different parameter value returns the same results

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: 2.3.2
    • Fix Version/s: None
    • Component/s: DQL, Mapping Drivers, ORM
    • Labels:
      None
    • Environment:
      Ubuntu 12.10, Zend Server CE

      Description

      $activeAdsCustomers = \Ez\Registry::getDoctrineEntityManager()
          ->createQuery( "SELECT c, a FROM \Spot101\Model\Ad\Customer c JOIN c.ads a WHERE a.status = :status" )
          ->setParameter( "status", \Spot101\Model\Ad\Status::ACTIVE )
          ->getResult();
      
      $inactiveAdsCustomers = \Ez\Registry::getDoctrineEntityManager()
          ->createQuery( "SELECT c, a FROM \Spot101\Model\Ad\Customer c JOIN c.ads a WHERE a.status = :status" )
          ->setParameter( "status", \Spot101\Model\Ad\Status::INACTIVE )
          ->getResult();
      

      Having the code above I am getting the same results for $inactiveAdsCustomers as I get for $activeAdsCustomers. And when I try hydrating the results everything works so fine.

      Both queries look the same except the value provided for the "status" parameter.

        Activity

        Mehdi Bakhtiari created issue -
        Marco Pivetta made changes -
        Field Original Value New Value
        Description $activeAdsCustomers = \Ez\Registry::getDoctrineEntityManager()->createQuery( "SELECT c, a FROM \Spot101\Model\Ad\Customer c JOIN c.ads a WHERE a.status = :status" )->setParameter( "status", \Spot101\Model\Ad\Status::ACTIVE )->getResult();

        $inactiveAdsCustomers = \Ez\Registry::getDoctrineEntityManager()->createQuery( "SELECT c, a FROM \Spot101\Model\Ad\Customer c JOIN c.ads a WHERE a.status = :status" )->setParameter( "status", \Spot101\Model\Ad\Status::INACTIVE )->getResult();

        Having the code above I am getting the same results for $inactiveAdsCustomers as I get for $activeAdsCustomers. And when I try hydrating the results everything works so fine.

        Both queries look the same except the value provided for the "status" parameter.
        {code}
        $activeAdsCustomers = \Ez\Registry::getDoctrineEntityManager()
            ->createQuery( "SELECT c, a FROM \Spot101\Model\Ad\Customer c JOIN c.ads a WHERE a.status = :status" )
            ->setParameter( "status", \Spot101\Model\Ad\Status::ACTIVE )
            ->getResult();

        $inactiveAdsCustomers = \Ez\Registry::getDoctrineEntityManager()
            ->createQuery( "SELECT c, a FROM \Spot101\Model\Ad\Customer c JOIN c.ads a WHERE a.status = :status" )
            ->setParameter( "status", \Spot101\Model\Ad\Status::INACTIVE )
            ->getResult();
        {code}

        Having the code above I am getting the same results for $inactiveAdsCustomers as I get for $activeAdsCustomers. And when I try hydrating the results everything works so fine.

        Both queries look the same except the value provided for the "status" parameter.
        Hide
        Marco Pivetta added a comment -

        You are hydrating joined and filtered resultsets. You should never do this, as this will hydrate an invalid association into your objects.

        Show
        Marco Pivetta added a comment - You are hydrating joined and filtered resultsets. You should never do this, as this will hydrate an invalid association into your objects.
        Marco Pivetta made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Benjamin Eberlei [ beberlei ] Marco Pivetta [ ocramius ]
        Resolution Invalid [ 6 ]

        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-2285, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Mehdi Bakhtiari
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: