@@ -108,7 +108,7 @@ class QueryResultTypeWalker extends SqlWalker
108
108
private $ hasGroupByClause ;
109
109
110
110
/** @var bool */
111
- private $ hasCondition ;
111
+ private $ hasWhereClause ;
112
112
113
113
/**
114
114
* @param Query<mixed> $query
@@ -138,7 +138,7 @@ public function __construct($query, $parserResult, array $queryComponents)
138
138
$ this ->nullableQueryComponents = [];
139
139
$ this ->hasAggregateFunction = false ;
140
140
$ this ->hasGroupByClause = false ;
141
- $ this ->hasCondition = false ;
141
+ $ this ->hasWhereClause = false ;
142
142
143
143
// The object is instantiated by Doctrine\ORM\Query\Parser, so receiving
144
144
// dependencies through the constructor is not an option. Instead, we
@@ -181,6 +181,7 @@ public function walkSelectStatement(AST\SelectStatement $AST)
181
181
$ this ->typeBuilder ->setSelectQuery ();
182
182
$ this ->hasAggregateFunction = $ this ->hasAggregateFunction ($ AST );
183
183
$ this ->hasGroupByClause = $ AST ->groupByClause !== null ;
184
+ $ this ->hasWhereClause = $ AST ->whereClause !== null ;
184
185
185
186
$ this ->walkFromClause ($ AST ->fromClause );
186
187
@@ -594,8 +595,6 @@ public function walkOrderByItem($orderByItem)
594
595
*/
595
596
public function walkHavingClause ($ havingClause )
596
597
{
597
- $ this ->hasCondition = true ;
598
-
599
598
return $ this ->marshalType (new MixedType ());
600
599
}
601
600
@@ -1011,8 +1010,6 @@ public function walkUpdateItem($updateItem)
1011
1010
*/
1012
1011
public function walkWhereClause ($ whereClause )
1013
1012
{
1014
- $ this ->hasCondition = true ;
1015
-
1016
1013
return $ this ->marshalType (new MixedType ());
1017
1014
}
1018
1015
@@ -1300,10 +1297,10 @@ public function walkResultVariable($resultVariable)
1300
1297
*/
1301
1298
private function addScalar ($ alias , Type $ type ): void
1302
1299
{
1303
- // Since we don't check the condition inside the WHERE or HAVING
1300
+ // Since we don't check the condition inside the WHERE
1304
1301
// conditions, we cannot be sure all the union types are correct.
1305
1302
// For exemple, a condition `WHERE foo.bar IS NOT NULL` could be added.
1306
- if ($ this ->hasCondition && $ type instanceof UnionType) {
1303
+ if ($ this ->hasWhereClause && $ type instanceof UnionType) {
1307
1304
$ type = TypeUtils::toBenevolentUnion ($ type );
1308
1305
}
1309
1306
0 commit comments