Skip to content

Commit 0251b01

Browse files
abnegateclaude
andcommitted
fix(joins): type the bounded page's filters as the builder's queries
PHPStan (level max) rejected passing the page's conditions, which are query-builder queries, to applyFilters(), which takes database queries so it can split out adapter-compiled filters. The bounded page never holds those (a read with any keeps the whole join), so the builder's own filter() takes the conditions as they are. The test narrows the mixed row values it formats or compares before using them as strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0c1b77f commit 0251b01

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/Database/Adapter/SQL.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5686,7 +5686,7 @@ private function boundJoinedSortToPage(
56865686

56875687
$page = $this->newBuilder($name, $alias);
56885688
$page->select([$alias.'.*']);
5689-
$this->applyFilters($page, $filters, $name, $alias);
5689+
$page->filter($filters);
56905690

56915691
if (
56925692
$this->authorization->getStatus()

‎tests/unit/Joins/BoundedJoinSortTest.php‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ public function testAnotherTenantsMainRowsTakeNoPlaceInTheBoundedPage(): void
238238
$this->assertCount(4, $expected);
239239
$this->assertSame($expected, $this->rows($bounding, $queries, []));
240240
foreach ($expected as $row) {
241+
$this->assertIsString($row['name']);
241242
$this->assertStringStartsWith($tenant === 1 ? 'one ' : 'two ', $row['name']);
242243
}
243244
}
@@ -318,7 +319,14 @@ private function keys(Database $database, array $queries, array $page): array
318319

319320
private function key(Document $row): string
320321
{
321-
return ($row->getId() ?: '-').'/'.($row->getAttribute('n.$id') ?? '-').'/'.($row->getAttribute('t.$id') ?? '-');
322+
return ($row->getId() ?: '-').'/'.$this->joinedId($row, 'n').'/'.$this->joinedId($row, 't');
323+
}
324+
325+
private function joinedId(Document $row, string $alias): string
326+
{
327+
$id = $row->getAttribute($alias.'.$id');
328+
329+
return \is_string($id) ? $id : '-';
322330
}
323331

324332
/**

0 commit comments

Comments
 (0)