diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 9cec30ffd..972199c5e 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -344,16 +344,28 @@ class BasicEntityPersister implements EntityPersister . ' FROM ' . $tableName . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?'; + + $flatId = $this->identifierFlattener->flattenIdentifier($versionedClass, $id); + + $value = $this->conn->fetchColumn( + $sql, + array_values($flatId), + 0, + $this->extractIdentifierTypes($id, $versionedClass) + ); + + return Type::getType($fieldMapping['type'])->convertToPHPValue($value, $this->platform); + } + + private function extractIdentifierTypes(array $id, ClassMetadata $versionedClass) : array + { $types = []; + foreach ($id as $field => $value) { $types = array_merge($types, $this->getTypes($field, $value, $versionedClass)); } - $flatId = $this->identifierFlattener->flattenIdentifier($versionedClass, $id); - - $value = $this->conn->fetchColumn($sql, array_values($flatId), 0, $types); - - return Type::getType($fieldMapping['type'])->convertToPHPValue($value, $this->platform); + return $types; } /**