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