Skip to content

Commit 2ed35ea

Browse files
Use benevolent union for scalar in queries
1 parent b62df47 commit 2ed35ea

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
@@ -795,7 +795,7 @@ public function walkSelectExpression($selectExpression)
795795

796796
$type = $this->resolveDoctrineType($typeName, $enumType, $nullable);
797797

798-
$this->typeBuilder->addScalar($resultAlias, $type);
798+
$this->addScalar($resultAlias, $type);
799799

800800
return '';
801801
}
@@ -855,7 +855,7 @@ public function walkSelectExpression($selectExpression)
855855
});
856856
}
857857

858-
$this->typeBuilder->addScalar($resultAlias, $type);
858+
$this->addScalar($resultAlias, $type);
859859

860860
return '';
861861
}
@@ -1276,6 +1276,18 @@ public function walkResultVariable($resultVariable)
12761276
return $this->marshalType(new MixedType());
12771277
}
12781278

1279+
/**
1280+
* @param array-key $alias
1281+
*/
1282+
private function addScalar($alias, Type $type): void
1283+
{
1284+
if ($type instanceof UnionType) {
1285+
$type = TypeUtils::toBenevolentUnion($type);
1286+
}
1287+
1288+
$this->typeBuilder->addScalar($alias, $type);
1289+
}
1290+
12791291
private function unmarshalType(string $marshalledType): Type
12801292
{
12811293
$type = unserialize($marshalledType);

0 commit comments

Comments
 (0)