You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I attempt to delete such an entity using the EntityManager, the JoinedSubclassPersister class is leveraged internally to perform the deletion and calls Connection::delete without passing along any field-mapping information as $types argument. This results in the following query being executed:
DELETE FROM my_entity WHERE id = 'Object(Ramsey\\Uuid\\Uuid)';
For my specific platform (which supports FK's) I've made a temporary fix by copying the $types assignment code from the BasicEntityPersister class, which looks like this:
// ...
// If the database platform supports FKs, just
// delete the row from the root table. Cascades do the rest.
if ($this->platform->supportsForeignKeyConstraints()) {
$rootClass = $this->em->getClassMetadata($this->class->rootEntityName);
$rootTable = $this->quoteStrategy->getTableName($rootClass, $this->platform);
$types = array_map(function ($identifier) use ($rootClass) {
if (isset($rootClass->fieldMappings[$identifier])) {
return $rootClass->fieldMappings[$identifier]['type'];
}
$targetMapping = $this->em->getClassMetadata($rootClass->associationMappings[$identifier]['targetEntity']);
if (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])) {
return $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
}
if (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])) {
return $targetMapping->associationMappings[$targetMapping->identifier[0]]['type'];
}
throw ORMException::unrecognizedField($targetMapping->identifier[0]);
}, $rootClass->identifier);
return (bool) $this->conn->delete($rootTable, $id, $types);
}
// ...
The text was updated successfully, but these errors were encountered:
fred-jan
changed the title
JoinedSubclassPersister::delete does not pass $types argument to the connection
JoinedSubclassPersister::delete does not pass $types argument to Connection::delete
Aug 23, 2016
fred-jan
added a commit
to MyOnlineStore/doctrine2
that referenced
this issue
Aug 23, 2016
My entity uses both class table inheritance and a custom id type (
uuid_binary
type provided by theramsey/uuid-doctrine
package). Simplified example:When I attempt to delete such an entity using the
EntityManager
, theJoinedSubclassPersister
class is leveraged internally to perform the deletion and callsConnection::delete
without passing along any field-mapping information as$types
argument. This results in the following query being executed:For my specific platform (which supports FK's) I've made a temporary fix by copying the
$types
assignment code from theBasicEntityPersister
class, which looks like this:The text was updated successfully, but these errors were encountered: