-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Description
Consider the following construct
#[ORM\Entity]
class A {
#[ORM\OneToOne(inversedBy: 'a', cascade: ['persist'], fetch: 'EXTRA_LAZY')]
private ?B $b = null;
}
#[ORM\Entity]
class B {
#[ORM\OneToOne(mappedBy: 'b')]
private A $a; // Default in constructor
}This results in:
------ ----------------------------------------------------------------------------------------------------------------
Line src/Entity/B.php
------ ----------------------------------------------------------------------------------------------------------------
29 Property App\Entity\B::$a type mapping mismatch: database can contain
App\Entity\A|null but property expects App\Entity\A.
🪪 doctrine.associationType
------ ----------------------------------------------------------------------------------------------------------------
However, this is a false positive, as the $a never even makes it to the database with this construction. The A holds an optional reference to the B object.
According to doctrine, when trying to add a join column definition to disallow a null value.
App\Entity\B#a is a OneToOne inverse side, which does not allow join columns.
Metadata
Metadata
Assignees
Labels
No labels