1
0
Fork 0
mirror of synced 2025-04-03 05:13:37 +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. 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)); $params = array_merge($params, $this->getValues($value));
} }
return array($params, $types); return array($params, $types);
@ -1860,24 +1860,17 @@ class BasicEntityPersister implements EntityPersister
break; break;
case (isset($class->associationMappings[$field])): case (isset($class->associationMappings[$field])):
$assoc = $class->associationMappings[$field]; $assoc = $class->associationMappings[$field];
$class = $this->em->getClassMetadata($assoc['targetEntity']); $class = $this->em->getClassMetadata($assoc['targetEntity']);
if (!$assoc['isOwningSide']) { if (!$assoc['isOwningSide']) {
$assoc = $class->associationMappings[$assoc['mappedBy']]; $assoc = $class->associationMappings[$assoc['mappedBy']];
$class = $this->em->getClassMetadata($assoc['targetEntity']); $class = $this->em->getClassMetadata($assoc['targetEntity']);
} }
if ($assoc['type'] === ClassMetadata::MANY_TO_MANY) { $columns = $assoc['type'] === ClassMetadata::MANY_TO_MANY
? $assoc['relationToTargetKeyColumns']
foreach ($assoc['relationToSourceKeyColumns'] as $field => $val){ : $assoc['sourceToTargetKeyColumns'];
$types = array_merge($types, PersisterHelper::getTypeOfField($val, $class, $this->em)); foreach ($columns as $column){
} $types[] = PersisterHelper::getTypeOfColumn($column, $class, $this->em);
} else {
foreach ($assoc['targetToSourceKeyColumns'] as $field => $val){
$types = array_merge($types, PersisterHelper::getTypeOfField($field, $class, $this->em));
}
} }
break; break;