Details
Description
Hi there,
I am using "Class Table Inheritance" and this are my entities.
** * @Entity * @Table (name="Vehicles") * @InheritanceType ("JOINED") * @DiscriminatorColumn (name="vehicleClass", type="string") * @DiscriminatorMap ({"own"="OwnCar", "renta"="RentedCar"}) */ class Vehicle { /** * @Id * @Column (name="vehicleID", type="integer") */ protected $vehicleID; /** * @Id * @Column (name="dateFrom", type="datetime") */ protected $dateFrom; ......... }
/** * @Table (name="OwnCars") * @Entity (repositoryClass="OwnCarRepo") */ class OwnCars_Model_Entity_OwnCar extends OwnCars_Model_Entity_Vehicle { }
As you can see i am using composed id keys. The problem that i get is when building the insert statement the value for the second key which is type datetime is not transformed to date transformed but cast to integer and in the data base i got inserted value of 0000-00-00 00:00:00 instead of the date that i have given. After i did a bit of debugging i found the problem to be in the "Doctrine\ORM\Persisters\JoinedSubclassPersister" on line 163.
foreach ((array) $id as $idVal) {
$stmt->bindValue($paramIndex++, $idVal);
}
As you can see when you are binding the values for the subtable ids you are not giving the type for the id. So for me to work i did a quick fix:
foreach ((array) $id as $columnNameIdentifier => $idVal) {
/**
* Fix untyped join inherited table.
* All identifiers was typed now.
*/
$type = \PDO::PARAM_STR;
if (isset($this->_columnTypes[$columnNameIdentifier])) {
$type = $this->_columnTypes[$columnNameIdentifier];
}
$stmt->bindValue($paramIndex++, $idVal, $type);
}
I hope that you will have time to take a look in to that problem soon as it is important for my project. Otherwise great work so far with the "ORM" ![]()
Have a nice day,
Victor
Issue Links
- is required for
-
DDC-1320
Ship Immutable date time with Doctrine Common, use in ORM - Should implement __toString()
-
Even if we fixed that it wouldn't work to have a DateTime as primary key. Since PK values need to be "stringable".