DDC-2034: getPartialReference returns partial entities for non existent entities #2569

Closed
opened 2026-01-22 13:57:12 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 17, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user deatheriam:

$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?

Originally created by @doctrinebot on GitHub (Sep 17, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user deatheriam: ``` $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?
admin added the Bug label 2026-01-22 13:57:12 +01:00
admin closed this issue 2026-01-22 13:57:12 +01:00
Author
Owner

@doctrinebot commented on GitHub (Sep 17, 2012):

Comment created by stof:

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

@doctrinebot commented on GitHub (Sep 17, 2012): Comment created by stof: 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
Author
Owner

@doctrinebot commented on GitHub (Sep 19, 2012):

Comment created by deatheriam:

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?

@doctrinebot commented on GitHub (Sep 19, 2012): Comment created by deatheriam: 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?
Author
Owner

@doctrinebot commented on GitHub (Oct 5, 2012):

Comment created by @beberlei:

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

@doctrinebot commented on GitHub (Oct 5, 2012): Comment created by @beberlei: the use case was partially removed by proxy objects now being capable of returning the id without querying.
Author
Owner

@doctrinebot commented on GitHub (Oct 5, 2012):

Issue was closed with resolution "Invalid"

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

No dependencies set.

Reference: doctrine/archived-orm#2569