DDC-2285: Repeating the same query with different parameter value returns the same results #2871

Closed
opened 2026-01-22 14:06:16 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 8, 2013).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user mehdone:

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

Originally created by @doctrinebot on GitHub (Feb 8, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user mehdone: ``` $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.
admin added the Bug label 2026-01-22 14:06:16 +01:00
admin closed this issue 2026-01-22 14:06:16 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 8, 2013):

Comment created by @ocramius:

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

@doctrinebot commented on GitHub (Feb 8, 2013): Comment created by @ocramius: You are hydrating joined and filtered resultsets. You should never do this, as this will hydrate an invalid association into your objects.
Author
Owner

@doctrinebot commented on GitHub (Feb 8, 2013):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Feb 8, 2013): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2871