diff --git a/CHANGELOG.md b/CHANGELOG.md index 00b321b7..ecaef217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ - Enh #371, #374: Adapt to conditions refactoring in `yiisoft/db` package (@vjik) - Enh #377: Remove `TableSchema` class and refactor `Schema` class (@Tigrov) - Enh #380: Support column's collation (@Tigrov) +- New #385: Add `Connection::getColumnBuilderClass()` method (@Tigrov) ## 1.2.0 March 21, 2024 diff --git a/src/Connection.php b/src/Connection.php index a76c40dd..3b57dc8b 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -10,6 +10,7 @@ use Yiisoft\Db\Schema\Quoter; use Yiisoft\Db\Schema\QuoterInterface; use Yiisoft\Db\Schema\SchemaInterface; +use Yiisoft\Db\Sqlite\Column\ColumnBuilder; use Yiisoft\Db\Sqlite\Column\ColumnFactory; use function str_starts_with; @@ -58,6 +59,11 @@ public function createTransaction(): Transaction return new Transaction($this); } + public function getColumnBuilderClass(): string + { + return ColumnBuilder::class; + } + public function getColumnFactory(): ColumnFactoryInterface { return $this->columnFactory ??= new ColumnFactory(); diff --git a/tests/ColumnBuilderTest.php b/tests/ColumnBuilderTest.php index 61f45283..52ea45d5 100644 --- a/tests/ColumnBuilderTest.php +++ b/tests/ColumnBuilderTest.php @@ -4,7 +4,6 @@ namespace Yiisoft\Db\Sqlite\Tests; -use Yiisoft\Db\Sqlite\Column\ColumnBuilder; use Yiisoft\Db\Sqlite\Tests\Support\TestTrait; use Yiisoft\Db\Tests\AbstractColumnBuilderTest; @@ -14,9 +13,4 @@ class ColumnBuilderTest extends AbstractColumnBuilderTest { use TestTrait; - - public function getColumnBuilderClass(): string - { - return ColumnBuilder::class; - } } diff --git a/tests/ColumnTest.php b/tests/ColumnTest.php index 9bf25768..5a86c1d9 100644 --- a/tests/ColumnTest.php +++ b/tests/ColumnTest.php @@ -15,7 +15,6 @@ use Yiisoft\Db\Schema\Column\IntegerColumn; use Yiisoft\Db\Schema\Column\JsonColumn; use Yiisoft\Db\Schema\Column\StringColumn; -use Yiisoft\Db\Sqlite\Column\ColumnBuilder; use Yiisoft\Db\Sqlite\Tests\Support\TestTrait; use Yiisoft\Db\Query\Query; use Yiisoft\Db\Tests\Common\CommonColumnTest; @@ -30,8 +29,6 @@ final class ColumnTest extends CommonColumnTest { use TestTrait; - protected const COLUMN_BUILDER = ColumnBuilder::class; - protected function insertTypeValues(ConnectionInterface $db): void { $command = $db->createCommand(); diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index c1b0f087..d85a273f 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -8,12 +8,10 @@ use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use Throwable; use Yiisoft\Db\Connection\ConnectionInterface; use Yiisoft\Db\Exception\Exception; -use Yiisoft\Db\Exception\InvalidConfigException; -use Yiisoft\Db\Exception\NotSupportedException; use Yiisoft\Db\Profiler\ProfilerInterface; +use Yiisoft\Db\Sqlite\Column\ColumnBuilder; use Yiisoft\Db\Sqlite\Column\ColumnFactory; use Yiisoft\Db\Sqlite\Connection; use Yiisoft\Db\Sqlite\Tests\Support\TestTrait; @@ -23,18 +21,11 @@ /** * @group sqlite - * - * @psalm-suppress PropertyNotSetInConstructor */ final class ConnectionTest extends CommonConnectionTest { use TestTrait; - /** - * @throws Exception - * @throws InvalidConfigException - * @throws Throwable - */ public function testExceptionContainsRawQuery(): void { $db = $this->getConnection(); @@ -73,10 +64,6 @@ public function testExceptionContainsRawQuery(): void $this->runExceptionTest($db); } - /** - * @throws Exception - * @throws InvalidConfigException - */ public function testSettingDefaultAttributes(): void { $db = $this->getConnection(); @@ -86,12 +73,6 @@ public function testSettingDefaultAttributes(): void $db->close(); } - /** - * @throws Exception - * @throws InvalidConfigException - * @throws NotSupportedException - * @throws Throwable - */ public function testTransactionIsolation(): void { $db = $this->getConnection(true); @@ -106,11 +87,6 @@ public function testTransactionIsolation(): void $this->assertTrue(true); } - /** - * @throws Exception - * @throws InvalidConfigException - * @throws Throwable - */ public function testTransactionShortcutCustom(): void { $db = $this->getConnection(true); @@ -143,9 +119,6 @@ protected function getLogger(): LoggerInterface|MockObject return $this->createMock(LoggerInterface::class); } - /** - * @throws Throwable - */ private function runExceptionTest(ConnectionInterface $db): void { $thrown = false; @@ -189,6 +162,15 @@ private function createProfiler(): ProfilerInterface return $this->createMock(ProfilerInterface::class); } + public function getColumnBuilderClass(): void + { + $db = $this->getConnection(); + + $this->assertSame(ColumnBuilder::class, $db->getColumnBuilderClass()); + + $db->close(); + } + public function testGetColumnFactory(): void { $db = $this->getConnection();