1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Right type detection on to-many relations

This commit is contained in:
Asmir Mustafic 2015-01-29 22:48:34 +01:00 committed by Marco Pivetta
parent 4323d9ce4c
commit 4d531d8855

View File

@ -1806,7 +1806,7 @@ class BasicEntityPersister implements EntityPersister
continue; // skip null values.
}
$types = array_merge($types, $this->getTypes($field, $value, $this->class));
$types = array_merge($types, $this->getTypes($field, $value, $this->class));
$params = array_merge($params, $this->getValues($value));
}
return array($params, $types);
@ -1860,24 +1860,17 @@ class BasicEntityPersister implements EntityPersister
break;
case (isset($class->associationMappings[$field])):
$assoc = $class->associationMappings[$field];
$class = $this->em->getClassMetadata($assoc['targetEntity']);
if (!$assoc['isOwningSide']) {
$assoc = $class->associationMappings[$assoc['mappedBy']];
$class = $this->em->getClassMetadata($assoc['targetEntity']);
}
if ($assoc['type'] === ClassMetadata::MANY_TO_MANY) {
foreach ($assoc['relationToSourceKeyColumns'] as $field => $val){
$types = array_merge($types, PersisterHelper::getTypeOfField($val, $class, $this->em));
}
} else {
foreach ($assoc['targetToSourceKeyColumns'] as $field => $val){
$types = array_merge($types, PersisterHelper::getTypeOfField($field, $class, $this->em));
}
$columns = $assoc['type'] === ClassMetadata::MANY_TO_MANY
? $assoc['relationToTargetKeyColumns']
: $assoc['sourceToTargetKeyColumns'];
foreach ($columns as $column){
$types[] = PersisterHelper::getTypeOfColumn($column, $class, $this->em);
}
break;