Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3069

[GH-1000] [DDC-3068] EntityManager::find accept array of object as id

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      This issue is created automatically through a Github pull request on behalf of giosh94mhz:

      Url: https://github.com/doctrine/doctrine2/pull/1000

      Message:

      Pull Request for ticket http://www.doctrine-project.org/jira/browse/DDC-3068
      Here follow the ticket description for you convenience.

      According to the documentation, ``EntityManager::find`` should return one entity given it's primary key. When a primary key of an entity is composed of multiple associations, one (me ) would expect that the following works, but it doesn't:
      ```php
      $entity = $_em->find('My\EntityClass', array(
      'assoc1' => $instance1,
      'assoc2' => $instance2
      ));
      PHP Fatal error: Object of class My\EntityClass could not be converted to string
      ```
      The only working way I've found is the following:
      ```php
      $entity = $_em->find('My\EntityClass', array(
      'assoc1' => $instance1->getId(),
      'assoc2' => $instance2->getId()
      ));
      ```
      I think that this second scenario is not correct, since expose implementation details.

        Activity

        Hide
        Doctrine Bot added a comment -

        A related Github Pull-Request [GH-1000] was closed:
        https://github.com/doctrine/doctrine2/pull/1000

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-1000] was closed: https://github.com/doctrine/doctrine2/pull/1000
        Show
        Guilherme Blanco added a comment - As of https://github.com/doctrine/doctrine2/commit/10a0daf6203b6d2ea0c92e30edb07ca7e83058b3 this issue was fixed.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Doctrine Bot
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: