DDC-2430: Incorrect results when using ->matching on PersistentCollection #3047

Closed
opened 2026-01-22 14:10:45 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (May 5, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user stuartcarnie:

When using ->matching() on a PersistentCollection that is already loaded, it returns incorrect results when trying to match by id on a relationship.

// NOTE: the user property is a M:1 relationship of $entity
$c = new Criteria(Criteria::expr()->eq('user', $userId));
$res = $entity->getLikes()->matching($c);

// $res is empty, even if $userId exists

Originally created by @doctrinebot on GitHub (May 5, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user stuartcarnie: When using ->matching() on a PersistentCollection that is already loaded, it returns incorrect results when trying to match by id on a relationship. // NOTE: the user property is a M:1 relationship of $entity $c = new Criteria(Criteria::expr()->eq('user', $userId)); $res = $entity->getLikes()->matching($c); // $res is empty, even if $userId exists
admin added the Bug label 2026-01-22 14:10:45 +01:00
admin closed this issue 2026-01-22 14:10:45 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 9, 2013):

Comment created by @beberlei:

The problem is that matching a user by just the id doesn't work for in memory here.
You should use Criteria::expr()->eq('user', $user) instead. The ORM shouldnt allow $userId matching, but this is generic functionality we are reusing here, pretty hard to enforce this. I can take a look.

@doctrinebot commented on GitHub (May 9, 2013): Comment created by @beberlei: The problem is that matching a user by just the id doesn't work for in memory here. You should use Criteria::expr()->eq('user', $user) instead. The ORM shouldnt allow $userId matching, but this is generic functionality we are reusing here, pretty hard to enforce this. I can take a look.
Author
Owner

@doctrinebot commented on GitHub (May 9, 2013):

Comment created by @beberlei:

Fixed and introduced a BC break for this.

See 30f90a6f49 (L0R31) for information.

@doctrinebot commented on GitHub (May 9, 2013): Comment created by @beberlei: Fixed and introduced a BC break for this. See https://github.com/doctrine/doctrine2/commit/30f90a6f49d46d2f367ac774aa77e0c7ce1a573f#L0R31 for information.
Author
Owner

@doctrinebot commented on GitHub (May 9, 2013):

Issue was closed with resolution "Fixed"

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

No dependencies set.

Reference: doctrine/archived-orm#3047