@@ -681,6 +681,82 @@ public function getTestData(): iterable
681681 ' ,
682682 ];
683683
684+ yield 'aggregate on literal ' => [
685+ $ this ->constantArray ([
686+ [
687+ new ConstantIntegerType (1 ),
688+ TypeCombinator::union (
689+ new ConstantStringType ('1 ' ),
690+ new ConstantIntegerType (1 ),
691+ new NullType ()
692+ ),
693+ ],
694+ [
695+ new ConstantIntegerType (2 ),
696+ TypeCombinator::union (
697+ new ConstantStringType ('0 ' ),
698+ new ConstantIntegerType (0 ),
699+ new ConstantStringType ('1 ' ),
700+ new ConstantIntegerType (1 ),
701+ new NullType ()
702+ ),
703+ ],
704+ [
705+ new ConstantIntegerType (3 ),
706+ TypeCombinator::union (
707+ new ConstantStringType ('1 ' ),
708+ new ConstantIntegerType (1 ),
709+ new NullType ()
710+ ),
711+ ],
712+ [
713+ new ConstantIntegerType (4 ),
714+ TypeCombinator::union (
715+ new ConstantStringType ('0 ' ),
716+ new ConstantIntegerType (0 ),
717+ new ConstantStringType ('1 ' ),
718+ new ConstantIntegerType (1 ),
719+ new NullType ()
720+ ),
721+ ],
722+ [
723+ new ConstantIntegerType (5 ),
724+ TypeCombinator::union (
725+ $ this ->intStringified (),
726+ new FloatType (),
727+ new NullType ()
728+ ),
729+ ],
730+ [
731+ new ConstantIntegerType (6 ),
732+ TypeCombinator::union (
733+ $ this ->intStringified (),
734+ new FloatType (),
735+ new NullType ()
736+ ),
737+ ],
738+ [
739+ new ConstantIntegerType (7 ),
740+ TypeCombinator::addNull ($ this ->intStringified ()),
741+ ],
742+ [
743+ new ConstantIntegerType (8 ),
744+ TypeCombinator::addNull ($ this ->intStringified ()),
745+ ],
746+ ]),
747+ '
748+ SELECT MAX(1),
749+ MAX(CASE WHEN m.intColumn = 0 THEN 1 ELSE 0 END),
750+ MIN(1),
751+ MIN(CASE WHEN m.intColumn = 0 THEN 1 ELSE 0 END),
752+ AVG(1),
753+ AVG(CASE WHEN m.intColumn = 0 THEN 1 ELSE 0 END),
754+ SUM(1),
755+ SUM(CASE WHEN m.intColumn = 0 THEN 1 ELSE 0 END)
756+ FROM QueryResult\Entities\Many m
757+ ' ,
758+ ];
759+
684760 yield 'literal ' => [
685761 $ this ->constantArray ([
686762 [
0 commit comments