Skip to content

Commit

Permalink
Fix persisting entity with nullable ManyToOne relation (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
javer authored Dec 21, 2021
1 parent 580bb37 commit 4a29088
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class DummyWithRelatedCascadePersist
*/
public Dummy $related;

/**
* @ManyToOne(targetEntity="Dummy", cascade={"persist"})
*/
public ?Dummy $relatedNullable = null;

/**
* @var Collection<AnotherDummy>
* @ManyToMany(targetEntity=AnotherDummy::class, cascade={"persist"})
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Doctrine/Persister/ObjectManagerPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private function checkAssociationsMetadata(ORMClassMetadataInfo $metadata, objec
foreach ($fieldValueOrFieldValues->getValues() as $fieldValue) {
$this->getMetadata($targetEntityClassName, $fieldValue);
}
} else {
} elseif ($fieldValueOrFieldValues !== null) {
$this->getMetadata($targetEntityClassName, $fieldValueOrFieldValues);
}
}
Expand Down

0 comments on commit 4a29088

Please sign in to comment.