Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2034

getPartialReference returns partial entities for non existent entities

    Details

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

      Description

      $variant = $em->getPartialReference('Entity\Variant', -1);
      echo $variant->getVariantId();
      

      prints -1. Is it an expected behavior or a bug? Shouldn't a check be made to prevent creating new instances for ids that do not exist?

        Activity

        Oleg Namaka created issue -
        Oleg Namaka made changes -
        Field Original Value New Value
        Description {code}
        $variant = $em->getPartialReference('Entity\Variant', -1);
        echo $variant->getVariantId();
        {code}

        prints -1. Is it an expected behavior or a bug?
        {code}
        $variant = $em->getPartialReference('Entity\Variant', -1);
        echo $variant->getVariantId();
        {code}

        prints -1. Is it an expected behavior or a bug? Shouldn't a check be made to prevent creating new instances for ids that do not exist?
        Hide
        Christophe Coevoet added a comment -

        Well, the purpose of getPartialReference is to return a reference without querying the database. So it cannot know if the id exists.
        https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/EntityManager.php#L481

        Show
        Christophe Coevoet added a comment - Well, the purpose of getPartialReference is to return a reference without querying the database. So it cannot know if the id exists. https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/EntityManager.php#L481
        Hide
        Oleg Namaka added a comment -

        Ok, in that case a user is responsible for providing a valid id. But what is a use case for such an entity? Can someone give me a real example?

        Show
        Oleg Namaka added a comment - Ok, in that case a user is responsible for providing a valid id. But what is a use case for such an entity? Can someone give me a real example?
        Hide
        Benjamin Eberlei added a comment -

        the use case was partially removed by proxy objects now being capable of returning the id without querying.

        Show
        Benjamin Eberlei added a comment - the use case was partially removed by proxy objects now being capable of returning the id without querying.
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2034, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Oleg Namaka
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: