DDC-2487: UnitOfWork::getEntityIdentifier() contains objects when custom mapping types are part of an entity's identity #3121

Open
opened 2026-01-22 14:12:54 +01:00 by admin · 0 comments
Owner

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 LocalDate class (mapped to a DATE field in the MySQL database).

Given the following entity:

/****
 * @Entity
 */
class Timeslot
{
    /****
     * @Id
     * @ManyToOne(targetEntity="Restaurant")
     */
    protected $restaurant;

    /****
     * @Id
     * @Column(type="localdate")
     */
    protected $date;
}

When var_export() -ing the result of UnitOfWork::getEntityIdentifier() on an instance of this class, the result is similar to:

array(
    'restaurant' => '5',
    'date' => LocalDate::*_set*state(array('year' => 2013, 'month' => 6, 'day' => 26))
)

This is a bit weird, because as far as I understand it, it should return the identity as it maps to database fields:

array(
    'restaurant' => '5',
    'date' => '2013-06-26'
)

If we take the $restaurant example, it returns the restaurant ID, and not the Restaurant entity, so my opinion is that it should be the same for $date.

Shouldn't the UnitOfWork use Type::convertToDatabaseValue() on custom mapping types to infer their value, when computing the identity of an entity?

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 `LocalDate` class (mapped to a `DATE` field in the MySQL database). Given the following entity: ``` /**** * @Entity */ class Timeslot { /**** * @Id * @ManyToOne(targetEntity="Restaurant") */ protected $restaurant; /**** * @Id * @Column(type="localdate") */ protected $date; } ``` When `var_export()` -ing the result of `UnitOfWork::getEntityIdentifier()` on an instance of this class, the result is similar to: ``` array( 'restaurant' => '5', 'date' => LocalDate::*_set*state(array('year' => 2013, 'month' => 6, 'day' => 26)) ) ``` This is a bit weird, because as far as I understand it, it should return the identity as it maps to database fields: ``` array( 'restaurant' => '5', 'date' => '2013-06-26' ) ``` If we take the `$restaurant` example, it returns the restaurant ID, and not the `Restaurant` entity, so my opinion is that it should be the same for `$date`. Shouldn't the `UnitOfWork` use `Type::convertToDatabaseValue()` on custom mapping types to infer their value, when computing the identity of an entity?
admin added the Bug label 2026-01-22 14:12:54 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3121