mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2487: UnitOfWork::getEntityIdentifier() contains objects when custom mapping types are part of an entity's identity #3124
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 (Jun 4, 2013).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user benjamin:
I'm using a custom mapping type for a
LocalDateclass (mapped to aDATEfield in the MySQL database).Given the following entity:
When
var_export()-ing the result ofUnitOfWork::getEntityIdentifier()on an instance of this class, the result is similar to:This is a bit weird, because as far as I understand it, it should return the identity as it maps to database fields:
If we take the
$restaurantexample, it returns the restaurant ID, and not theRestaurantentity, so my opinion is that it should be the same for$date.Shouldn't the
UnitOfWorkuseType::convertToDatabaseValue()on custom mapping types to infer their value, when computing the identity of an entity?@doctrinebot commented on GitHub (Jun 4, 2013):
@doctrinebot commented on GitHub (Jun 4, 2013):
Comment created by @ocramius:
[~benjamin] why would getEntityIdentifier convert types? The UoW doesn't worry about the DBAL representation of the objects - actually, the UoW doesn't know of the DBAL at all.
@doctrinebot commented on GitHub (Jun 4, 2013):
Comment created by benjamin:
Your point is valid, but that's still annoying. Why would getEntityIdentifier() return objects?
By the way,
UnitOfWorkis aware ofEntityManager, and thus theConnection, and thus thePlatform!It does use the
Connectionincommit().@doctrinebot commented on GitHub (Jun 4, 2013):
Comment created by @ocramius:
[~benjamin] that is because that is the identifier in your object. It's composed by the identifier of an associated entity and a datetime object (scalar)
@doctrinebot commented on GitHub (Jun 4, 2013):
Comment created by benjamin:
[~ocramius] Then why does it return the restaurant ID, and not the
Restaurantobject?@doctrinebot commented on GitHub (Dec 22, 2013):
Comment created by @beberlei:
This is not a bug, it is just how it works, the docblock says nothing about how the fields have to look. The UnitOfWork API is mostly serving itself and optimized for that.
@doctrinebot commented on GitHub (Dec 22, 2013):
Issue was closed with resolution "Invalid"