Skip to content

Commit f4ec555

Browse files
Use benevolent union for scalar in queries
1 parent a1ba454 commit f4ec555

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Diff for: src/Type/Doctrine/Query/QueryResultTypeWalker.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ public function walkSelectExpression($selectExpression)
794794

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

797-
$this->typeBuilder->addScalar($resultAlias, $type);
797+
$this->addScalar($resultAlias, $type);
798798

799799
return '';
800800
}
@@ -854,7 +854,7 @@ public function walkSelectExpression($selectExpression)
854854
});
855855
}
856856

857-
$this->typeBuilder->addScalar($resultAlias, $type);
857+
$this->addScalar($resultAlias, $type);
858858

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

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

0 commit comments

Comments
 (0)