mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2430: Incorrect results when using ->matching on PersistentCollection #3047
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
@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:
Fixed and introduced a BC break for this.
See
30f90a6f49 (L0R31)for information.@doctrinebot commented on GitHub (May 9, 2013):
Issue was closed with resolution "Fixed"