diff --git a/src/Type/Doctrine/Query/QueryResultTypeWalker.php b/src/Type/Doctrine/Query/QueryResultTypeWalker.php index 1f592e42..30207634 100644 --- a/src/Type/Doctrine/Query/QueryResultTypeWalker.php +++ b/src/Type/Doctrine/Query/QueryResultTypeWalker.php @@ -550,6 +550,7 @@ public function walkFunction($function) } $nullable = ($joinColumn['nullable'] ?? true) + || $this->isQueryComponentNullable($dqlAlias) || $this->hasAggregateWithoutGroupBy(); $fieldType = $this->resolveDatabaseInternalType($typeName, $enumType, $nullable); diff --git a/tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php b/tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php index 499a0732..31b99c8e 100644 --- a/tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php +++ b/tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php @@ -1377,6 +1377,7 @@ public function getTestData(): iterable [new ConstantIntegerType(6), TypeCombinator::addNull($this->numericStringOrInt())], [new ConstantIntegerType(7), TypeCombinator::addNull(new MixedType())], [new ConstantIntegerType(8), TypeCombinator::addNull($this->numericStringOrInt())], + [new ConstantIntegerType(9), TypeCombinator::addNull($this->numericStringOrInt())], ]), ' SELECT IDENTITY(m.oneNull), @@ -1386,8 +1387,10 @@ public function getTestData(): iterable IDENTITY(m.compoundPk, \'id\'), IDENTITY(m.compoundPk, \'version\'), IDENTITY(m.compoundPkAssoc), - IDENTITY(m.compoundPkAssoc, \'version\') + IDENTITY(m.compoundPkAssoc, \'version\'), + IDENTITY(o.subOne) FROM QueryResult\Entities\Many m + LEFT JOIN m.oneNull o ', ]; diff --git a/tests/Type/Doctrine/data/QueryResult/Entities/One.php b/tests/Type/Doctrine/data/QueryResult/Entities/One.php index f6ef5b10..5605c945 100644 --- a/tests/Type/Doctrine/data/QueryResult/Entities/One.php +++ b/tests/Type/Doctrine/data/QueryResult/Entities/One.php @@ -8,8 +8,8 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; +use Doctrine\ORM\Mapping\OneToOne; /** * @Entity @@ -45,6 +45,14 @@ class One */ public $stringNullColumn; + /** + * @OneToOne(targetEntity="QueryResult\Entities\SubOne", cascade={"persist"}) + * @JoinColumn(nullable=false) + * + * @var SubOne + */ + public $subOne; + /** * @OneToMany(targetEntity="QueryResult\Entities\Many", mappedBy="one") * @@ -58,4 +66,9 @@ class One * @var Embedded */ public $embedded; + + public function __construct() + { + $this->subOne = new SubOne(); + } } diff --git a/tests/Type/Doctrine/data/QueryResult/Entities/SubOne.php b/tests/Type/Doctrine/data/QueryResult/Entities/SubOne.php new file mode 100644 index 00000000..db7114aa --- /dev/null +++ b/tests/Type/Doctrine/data/QueryResult/Entities/SubOne.php @@ -0,0 +1,23 @@ +