Skip to content

Commit a223e35

Browse files
janedbalondrejmirtes
authored andcommitted
Lowercase aggregate functions should not be inferred as mixed
1 parent 4058fdc commit a223e35

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
use function serialize;
5151
use function sprintf;
5252
use function strtolower;
53+
use function strtoupper;
5354
use function unserialize;
5455

5556
/**
@@ -930,7 +931,7 @@ public function walkSimpleSelectExpression($simpleSelectExpression): string
930931
*/
931932
public function walkAggregateExpression($aggExpression): string
932933
{
933-
switch ($aggExpression->functionName) {
934+
switch (strtoupper($aggExpression->functionName)) {
934935
case 'MAX':
935936
case 'MIN':
936937
$type = $this->unmarshalType(

Diff for: tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,19 @@ public function getTestData(): iterable
645645
',
646646
];
647647

648+
yield 'aggregate lowercase' => [
649+
$this->constantArray([
650+
[
651+
new ConstantStringType('foo'),
652+
TypeCombinator::addNull($this->numericStringified()),
653+
],
654+
]),
655+
'
656+
SELECT avg(m.intColumn) as foo
657+
FROM QueryResult\Entities\Many m
658+
',
659+
];
660+
648661
yield 'aggregate with group by' => [
649662
$this->constantArray([
650663
[

0 commit comments

Comments
 (0)