Skip to content

Commit

Permalink
Fix subselect aggregate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharylund authored and ondrejmirtes committed Jul 12, 2024
1 parent 21eb848 commit 3f2cb3d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function walkNode($node): void
return;
}

if ($node instanceof AST\Subselect) {
return;
}

if ($this->isAggregateFunction($node)) {
$this->markAggregateFunctionFound();
return;
Expand Down
16 changes: 16 additions & 0 deletions tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3f2cb3d

Please sign in to comment.