[DDC-2034] getPartialReference returns partial entities for non existent entities Created: 17/Sep/12 Updated: 05/Oct/12 Resolved: 05/Oct/12 |
|
| Status: | Resolved |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Oleg Namaka | Assignee: | Benjamin Eberlei |
| Resolution: | Invalid | Votes: | 0 |
| 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? |
| Comments |
| Comment by Christophe Coevoet [ 17/Sep/12 ] |
|
Well, the purpose of getPartialReference is to return a reference without querying the database. So it cannot know if the id exists. |
| Comment by Oleg Namaka [ 19/Sep/12 ] |
|
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? |
| Comment by Benjamin Eberlei [ 05/Oct/12 ] |
|
the use case was partially removed by proxy objects now being capable of returning the id without querying. |