Skip to content

Commit

Permalink
Merge pull request #654 from doctrine/revert-651-master
Browse files Browse the repository at this point in the history
Revert "Check nullable fields on handleTypeConversions method"
  • Loading branch information
TomHAnderson authored Oct 17, 2018
2 parents 57cf4bb + 987b690 commit b983286
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
8 changes: 0 additions & 8 deletions src/DoctrineModule/Stdlib/Hydrator/DoctrineObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,6 @@ public function hydrateValue($name, $value, $data = null)
{
$value = parent::hydrateValue($name, $value, $data);

if (is_null($value) && method_exists($this->metadata, 'isNullable') && $this->metadata->isNullable($name)) {
return null;
}

return $this->handleTypeConversions($value, $this->metadata->getTypeOfField($name));
}

Expand Down Expand Up @@ -539,10 +535,6 @@ function ($item) {
*/
protected function handleTypeConversions($value, $typeOfField)
{
if (is_null($value)) {
return null;
}

switch ($typeOfField) {
case 'boolean':
$value = (bool)$value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,26 +621,4 @@ public function testHandleTypeConversionsDecimal()
$this->assertTrue(is_string($entity->getGenericField()));
$this->assertEquals('12345', $entity->getGenericField());
}

public function testHandleTypeConversionsNullable()
{
// When using hydration by value, it will use the public API of the entity to set values (setters)
$this->configureObjectManagerForSimpleEntityWithGenericField(null);

$entity = new Asset\SimpleEntityWithGenericField();
$data = ['genericField' => null];

$entity = $this->hydratorByValue->hydrate($data, $entity);

$this->assertTrue(is_null($entity->getGenericField()));
$this->assertEquals(null, $entity->getGenericField());

$entity = new Asset\SimpleEntityWithGenericField();
$data = ['genericField' => null];

$entity = $this->hydratorByReference->hydrate($data, $entity);

$this->assertTrue(is_null($entity->getGenericField()));
$this->assertEquals(null, $entity->getGenericField());
}
}

0 comments on commit b983286

Please sign in to comment.