Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2430

Incorrect results when using ->matching on PersistentCollection

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.4
    • Component/s: ORM
    • Security Level: All
    • Labels:
    • Environment:
      Ubuntu 12.04 LTS, PHP 5.4.14

      Description

      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

        Activity

        Hide
        Benjamin Eberlei added a comment -

        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.

        Show
        Benjamin Eberlei added a comment - 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.
        Hide
        Benjamin Eberlei added a comment -

        Fixed and introduced a BC break for this.

        See https://github.com/doctrine/doctrine2/commit/30f90a6f49d46d2f367ac774aa77e0c7ce1a573f#L0R31 for information.

        Show
        Benjamin Eberlei added a comment - Fixed and introduced a BC break for this. See https://github.com/doctrine/doctrine2/commit/30f90a6f49d46d2f367ac774aa77e0c7ce1a573f#L0R31 for information.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Stuart Carnie
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: