From a0f400518b42170dee80e23fc3fa33e7bb4cd2b1 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 15 Aug 2025 00:24:50 +0300 Subject: [PATCH 1/2] Add `Connection::getColumnBuilderClass()` --- src/Connection.php | 6 ++++++ tests/ColumnBuilderTest.php | 12 +++--------- tests/ColumnTest.php | 2 -- tests/ConnectionTest.php | 36 ++++++++++-------------------------- 4 files changed, 19 insertions(+), 37 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 5189734d..4678d445 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -12,6 +12,7 @@ use InvalidArgumentException; use Yiisoft\Db\Exception\InvalidCallException; use Yiisoft\Db\Exception\InvalidConfigException; +use Yiisoft\Db\Oracle\Column\ColumnBuilder; use Yiisoft\Db\Oracle\Column\ColumnFactory; use Yiisoft\Db\QueryBuilder\QueryBuilderInterface; use Yiisoft\Db\Schema\Column\ColumnFactoryInterface; @@ -50,6 +51,11 @@ public function createTransaction(): TransactionInterface 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 d75fffaf..9f5a50e1 100644 --- a/tests/ColumnBuilderTest.php +++ b/tests/ColumnBuilderTest.php @@ -4,7 +4,8 @@ namespace Yiisoft\Db\Oracle\Tests; -use Yiisoft\Db\Oracle\Column\ColumnBuilder; +use PHPUnit\Framework\Attributes\DataProviderExternal; +use Yiisoft\Db\Oracle\Tests\Provider\ColumnBuilderProvider; use Yiisoft\Db\Oracle\Tests\Support\TestTrait; use Yiisoft\Db\Tests\AbstractColumnBuilderTest; @@ -15,14 +16,7 @@ class ColumnBuilderTest extends AbstractColumnBuilderTest { use TestTrait; - public function getColumnBuilderClass(): string - { - return ColumnBuilder::class; - } - - /** - * @dataProvider \Yiisoft\Db\Oracle\Tests\Provider\ColumnBuilderProvider::buildingMethods - */ + #[DataProviderExternal(ColumnBuilderProvider::class, 'buildingMethods')] public function testBuildingMethods( string $buildingMethod, array $args, diff --git a/tests/ColumnTest.php b/tests/ColumnTest.php index 8360ddb8..975966be 100644 --- a/tests/ColumnTest.php +++ b/tests/ColumnTest.php @@ -35,8 +35,6 @@ final class ColumnTest extends CommonColumnTest { use TestTrait; - protected const COLUMN_BUILDER = ColumnBuilder::class; - protected function insertTypeValues(ConnectionInterface $db): void { $db->createCommand()->insert( diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 78d0b245..3dae7049 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -5,12 +5,9 @@ namespace Yiisoft\Db\Oracle\Tests; use PDO; -use Throwable; use Yiisoft\Db\Connection\ConnectionInterface; use Yiisoft\Db\Driver\Pdo\PdoConnectionInterface; -use Yiisoft\Db\Exception\Exception; -use Yiisoft\Db\Exception\InvalidConfigException; -use Yiisoft\Db\Exception\NotSupportedException; +use Yiisoft\Db\Oracle\Column\ColumnBuilder; use Yiisoft\Db\Oracle\Column\ColumnFactory; use Yiisoft\Db\Oracle\Connection; use Yiisoft\Db\Oracle\Tests\Support\TestTrait; @@ -20,18 +17,11 @@ /** * @group oracle - * - * @psalm-suppress PropertyNotSetInConstructor */ final class ConnectionTest extends CommonConnectionTest { use TestTrait; - /** - * @throws Exception - * @throws InvalidConfigException - * @throws Throwable - */ public function testSerialize(): void { $db = $this->getConnection(); @@ -46,10 +36,6 @@ public function testSerialize(): void $db->close(); } - /** - * @throws Exception - * @throws InvalidConfigException - */ public function testSettingDefaultAttributes(): void { $db = $this->getConnection(); @@ -59,12 +45,6 @@ public function testSettingDefaultAttributes(): void $db->close(); } - /** - * @throws Exception - * @throws InvalidConfigException - * @throws NotSupportedException - * @throws Throwable - */ public function testTransactionIsolation(): void { $db = $this->getConnection(); @@ -84,11 +64,6 @@ public function testTransactionIsolation(): void $db->close(); } - /** - * @throws Exception - * @throws InvalidConfigException - * @throws Throwable - */ public function testTransactionShortcutCustom(): void { $db = $this->getConnection(true); @@ -134,6 +109,15 @@ public function testSerialized(): void $this->assertNotNull($connection->getPDO()); } + public function getColumnBuilderClass(): void + { + $db = $this->getConnection(); + + $this->assertSame(ColumnBuilder::class, $db->getColumnBuilderClass()); + + $db->close(); + } + public function testGetColumnFactory(): void { $db = $this->getConnection(); From 522755ff0c0a61c6e3c48b41fdb7ad450b5bff41 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 15 Aug 2025 00:44:21 +0300 Subject: [PATCH 2/2] Add line to CHANGELOG.md [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 626e03b3..c10eeb02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ - Enh #348: Remove `TableSchema` class and refactor `Schema` class (@Tigrov) - Enh #350: Adapt to `Like` changes in `yiisoft/db` package (@vjik) - Enh #352: Support column's collation (@Tigrov) +- New #358: Add `Connection::getColumnBuilderClass()` method (@Tigrov) ## 1.3.0 March 21, 2024