Skip to content

Commit 2f6eb75

Browse files
Use benevolent union for scalar in queries
1 parent 0f41093 commit 2f6eb75

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Type/Doctrine/Query/QueryResultTypeWalker.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ public function walkSelectExpression($selectExpression): string
797797

798798
$type = $this->resolveDoctrineType($typeName, $enumType, $nullable);
799799

800-
$this->typeBuilder->addScalar($resultAlias, $type);
800+
$this->addScalar($resultAlias, $type);
801801

802802
return '';
803803
}
@@ -857,7 +857,7 @@ public function walkSelectExpression($selectExpression): string
857857
});
858858
}
859859

860-
$this->typeBuilder->addScalar($resultAlias, $type);
860+
$this->addScalar($resultAlias, $type);
861861

862862
return '';
863863
}
@@ -1298,6 +1298,18 @@ public function walkResultVariable($resultVariable): string
12981298
return $this->marshalType(new MixedType());
12991299
}
13001300

1301+
/**
1302+
* @param array-key $alias
1303+
*/
1304+
private function addScalar($alias, Type $type): void
1305+
{
1306+
if ($type instanceof UnionType) {
1307+
$type = TypeUtils::toBenevolentUnion($type);
1308+
}
1309+
1310+
$this->typeBuilder->addScalar($alias, $type);
1311+
}
1312+
13011313
private function unmarshalType(string $marshalledType): Type
13021314
{
13031315
$type = unserialize($marshalledType);

0 commit comments

Comments
 (0)