mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-773: When a partial reference exists, ::find() return partial objects #953
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Aug 27, 2010).
Jira issue originally created by user arnaud-lb:
In the following example, the object returned by EntityManager::find() is a partial object (the partial reference) :
@doctrinebot commented on GitHub (Aug 27, 2010):
Comment created by romanb:
This is not a bug. Partial objects are managed just like other ones.
@doctrinebot commented on GitHub (Aug 27, 2010):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Aug 27, 2010):
Comment created by arnaud-lb:
I would not expect EntityManager::find() to return a partial object. Maybe find() should return a new, non-partial object; or update the existing partial.
The current behavior will surely be the cause of non-obvious bugs.
@doctrinebot commented on GitHub (Aug 27, 2010):
Comment created by @beberlei:
Maybe we should document this behaviour more clearly in the docblock and add a warning.
This is the desired behaviour of getPartialReference().
@doctrinebot commented on GitHub (Aug 27, 2010):
Comment created by romanb:
@"The current behavior will surely be the cause of non-obvious bugs."
Yes, that is absolutely right but that is the risk of using partial objects. You can run into a lot of different issues with them. That's why you should only use them when you really know what you're doing and when you want to take the risk, ideally always making the scope of partial objects as small as possible.
For example, when you ->detach($partial) as soon as you're done with it, you can avoid this problem.
Example: