Skip to content

Commit 81d2fc0

Browse files
abnegateclaude
andcommitted
test(query): count a distinct join without a select
MySQL refuses a derived table with two columns of the same name. A distinct join without a select projects the main table's columns next to the joined `r._uid`, so the count holds it to keep those names apart on every adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4eda93a commit 81d2fc0

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

‎tests/e2e/Adapter/Scopes/AggregationTests.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,7 @@ public function testCountMatchesTheRowsOfGroupedDistinctAndAggregateReads(): voi
28452845
'join with groupBy' => [[$join, Query::count('*', 'n'), Query::groupBy(['category'])], 4, 2],
28462846
'distinct over a join' => [[$join, Query::distinct(), Query::select(['category'])], 4, 2],
28472847
'distinct joined attribute' => [[$join, Query::distinct(), Query::select(['r.score'])], 5, 2],
2848+
'distinct over a join without a select' => [[$join, Query::distinct()], 6, 3],
28482849
'full outer join with groupBy' => [[$fullOuterJoin, Query::count('*', 'n'), Query::groupBy(['r.score'])], null, null],
28492850
'full outer join with distinct' => [[$fullOuterJoin, Query::distinct(), Query::select(['category'])], null, null],
28502851
];

‎tests/unit/RowCountTest.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public static function shapes(): array
8181
'join with groupBy' => [[$join, Query::count('*', 'n'), Query::groupBy(['category'])], 4, 2],
8282
'distinct over a join' => [[$join, Query::distinct(), Query::select(['category'])], 4, 2],
8383
'distinct joined attribute' => [[$join, Query::distinct(), Query::select(['r.score'])], 5, 2],
84+
'distinct over a join without a select' => [[$join, Query::distinct()], 6, 3],
8485
'emulated full outer join with groupBy' => [[$fullOuterJoin, Query::count('*', 'n'), Query::groupBy(['category'])], 4, 4],
8586
'emulated full outer join with distinct' => [[$fullOuterJoin, Query::distinct(), Query::select(['r.score'])], 6, 5],
8687
];

0 commit comments

Comments
 (0)