Skip to content

Commit 30dfc48

Browse files
abnegateclaude
andcommitted
test: give the full-outer-join SQLite adapters a named scoped builder
Both test adapters returned an anonymous builder using ScopesCollections, and PHPStan, analysing the trait in the context of one of them, lost its typed per-build callbacks. A named FullOuterJoinSQLiteBuilder serves both, and the import order pint expects is restored in MongoDatabaseRenameTest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent dbb3755 commit 30dfc48

5 files changed

Lines changed: 24 additions & 19 deletions

File tree

‎src/Database/Builder/ScopesCollections.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Utopia\Database\Builder;
44

5-
use Closure;
65
use Utopia\Database\Exception\Query as QueryException;
76
use Utopia\Query\Builder\Statement;
87
use Utopia\Query\Query;
@@ -24,7 +23,9 @@ trait ScopesCollections
2423

2524
private string $boundAlias = '';
2625

27-
/** @var list<Closure(): void> */
26+
/**
27+
* @var list<\Closure(): void>
28+
*/
2829
private array $beforeEachBuild = [];
2930

3031
#[\Override]

‎tests/unit/MongoDatabaseRenameTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use PHPUnit\Framework\TestCase;
66
use Utopia\Database\Adapter\Mongo;
7-
use Utopia\Database\Exception\Duplicate as DuplicateException;
87
use Utopia\Database\Exception as DatabaseException;
8+
use Utopia\Database\Exception\Duplicate as DuplicateException;
99
use Utopia\Mongo\Exception as MongoException;
1010

1111
final class MongoDatabaseRenameTest extends TestCase
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Tests\Unit\Support;
4+
5+
use Utopia\Database\Builder\ScopesCollections;
6+
use Utopia\Database\Builder\Scoping;
7+
use Utopia\Query\Builder\Feature\FullOuterJoins;
8+
use Utopia\Query\Builder\SQLite;
9+
use Utopia\Query\Builder\Trait\FullOuterJoins as FullOuterJoinsTrait;
10+
11+
/**
12+
* The SQLite builder with FULL OUTER JOIN (SQLite 3.39+), scoped as the adapter's builder is.
13+
*/
14+
final class FullOuterJoinSQLiteBuilder extends SQLite implements FullOuterJoins, Scoping
15+
{
16+
use FullOuterJoinsTrait;
17+
use ScopesCollections;
18+
}

‎tests/unit/Support/NativeFullOuterJoinSQLite.php‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
use Override;
66
use Utopia\Database\Adapter\SQLite;
7-
use Utopia\Database\Builder\ScopesCollections;
87
use Utopia\Database\Builder\Scoping;
9-
use Utopia\Query\Builder\Feature\FullOuterJoins;
108
use Utopia\Query\Builder\SQL as SQLBuilder;
11-
use Utopia\Query\Builder\SQLite as SQLiteBuilder;
12-
use Utopia\Query\Builder\Trait\FullOuterJoins as FullOuterJoinsTrait;
139

1410
/**
1511
* SQLite that runs FULL OUTER JOIN natively (SQLite 3.39+) instead of emulating it with a
@@ -20,9 +16,6 @@ final class NativeFullOuterJoinSQLite extends SQLite
2016
#[Override]
2117
protected function dialectBuilder(): SQLBuilder&Scoping
2218
{
23-
return new class () extends SQLiteBuilder implements FullOuterJoins, Scoping {
24-
use FullOuterJoinsTrait;
25-
use ScopesCollections;
26-
};
19+
return new FullOuterJoinSQLiteBuilder();
2720
}
2821
}

‎tests/unit/Support/NativeJoinChainSQLite.php‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
use Override;
66
use Utopia\Database\Adapter\SQLite;
7-
use Utopia\Database\Builder\ScopesCollections;
87
use Utopia\Database\Builder\Scoping;
9-
use Utopia\Query\Builder\Feature\FullOuterJoins;
108
use Utopia\Query\Builder\SQL as SQLBuilder;
11-
use Utopia\Query\Builder\SQLite as SQLiteBuilder;
12-
use Utopia\Query\Builder\Trait\FullOuterJoins as FullOuterJoinsTrait;
139

1410
/**
1511
* SQLite running FULL OUTER JOIN natively (3.39+), the single statement PostgreSQL runs, as the
@@ -20,9 +16,6 @@ final class NativeJoinChainSQLite extends SQLite
2016
#[Override]
2117
protected function dialectBuilder(): SQLBuilder&Scoping
2218
{
23-
return new class () extends SQLiteBuilder implements FullOuterJoins, Scoping {
24-
use FullOuterJoinsTrait;
25-
use ScopesCollections;
26-
};
19+
return new FullOuterJoinSQLiteBuilder();
2720
}
2821
}

0 commit comments

Comments
 (0)