diff --git a/src/Type/Doctrine/Query/QueryAggregateFunctionDetectorTreeWalker.php b/src/Type/Doctrine/Query/QueryAggregateFunctionDetectorTreeWalker.php index c82527a3..7e891222 100644 --- a/src/Type/Doctrine/Query/QueryAggregateFunctionDetectorTreeWalker.php +++ b/src/Type/Doctrine/Query/QueryAggregateFunctionDetectorTreeWalker.php @@ -25,6 +25,10 @@ public function walkNode($node): void return; } + if ($node instanceof AST\Subselect) { + return; + } + if ($this->isAggregateFunction($node)) { $this->markAggregateFunctionFound(); return; diff --git a/tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php b/tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php index 4df903c0..04fdcba8 100644 --- a/tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php +++ b/tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php @@ -3833,6 +3833,22 @@ public static function provideCases(): iterable 'stringify' => self::STRINGIFY_NONE, ]; + yield 'SUBSELECT' => [ + 'data' => self::dataDefault(), + 'select' => 'SELECT t1.col_int, (SELECT COUNT(t2.col_int) FROM ' . PlatformEntity::class . ' t2) FROM %s t1', + 'mysql' => self::int(), + 'sqlite' => self::int(), + 'pdo_pgsql' => self::int(), + 'pgsql' => self::int(), + 'mssql' => self::int(), + 'mysqlResult' => 9, + 'sqliteResult' => 9, + 'pdoPgsqlResult' => 9, + 'pgsqlResult' => 9, + 'mssqlResult' => 9, + 'stringify' => self::STRINGIFY_NONE, + ]; + yield 'COUNT(t.col_int)' => [ 'data' => self::dataDefault(), 'select' => 'SELECT COUNT(t.col_int) FROM %s t',