Skip to content

Commit af7864f

Browse files
authored
Add Connection::getColumnBuilderClass() (#440)
1 parent ee45811 commit af7864f

5 files changed

Lines changed: 20 additions & 36 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
- Enh #424, #425, #428: Adapt to conditions refactoring in `yiisoft/db` package (@vjik)
5151
- Enh #431: Remove `TableSchema` class and refactor `Schema` class (@Tigrov)
5252
- Enh #433: Support column's collation (@Tigrov)
53+
- New #440: Add `Connection::getColumnBuilderClass()` method (@Tigrov)
5354

5455
## 1.3.0 March 21, 2024
5556

src/Connection.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Yiisoft\Db\Driver\Pdo\AbstractPdoConnection;
88
use Yiisoft\Db\Driver\Pdo\PdoCommandInterface;
99
use InvalidArgumentException;
10+
use Yiisoft\Db\Pgsql\Column\ColumnBuilder;
1011
use Yiisoft\Db\Pgsql\Column\ColumnFactory;
1112
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
1213
use Yiisoft\Db\Schema\Column\ColumnFactoryInterface;
@@ -46,6 +47,11 @@ public function createTransaction(): TransactionInterface
4647
return new Transaction($this);
4748
}
4849

50+
public function getColumnBuilderClass(): string
51+
{
52+
return ColumnBuilder::class;
53+
}
54+
4955
public function getColumnFactory(): ColumnFactoryInterface
5056
{
5157
return $this->columnFactory ??= new ColumnFactory();

tests/ColumnBuilderTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace Yiisoft\Db\Pgsql\Tests;
66

7-
use Yiisoft\Db\Pgsql\Column\ColumnBuilder;
7+
use PHPUnit\Framework\Attributes\DataProviderExternal;
8+
use Yiisoft\Db\Pgsql\Tests\Provider\ColumnBuilderProvider;
89
use Yiisoft\Db\Pgsql\Tests\Support\TestTrait;
910
use Yiisoft\Db\Tests\AbstractColumnBuilderTest;
1011

@@ -15,14 +16,7 @@ final class ColumnBuilderTest extends AbstractColumnBuilderTest
1516
{
1617
use TestTrait;
1718

18-
public function getColumnBuilderClass(): string
19-
{
20-
return ColumnBuilder::class;
21-
}
22-
23-
/**
24-
* @dataProvider \Yiisoft\Db\Pgsql\Tests\Provider\ColumnBuilderProvider::buildingMethods
25-
*/
19+
#[DataProviderExternal(ColumnBuilderProvider::class, 'buildingMethods')]
2620
public function testBuildingMethods(
2721
string $buildingMethod,
2822
array $args,

tests/ColumnTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ final class ColumnTest extends CommonColumnTest
4040
{
4141
use TestTrait;
4242

43-
protected const COLUMN_BUILDER = ColumnBuilder::class;
44-
4543
protected function insertTypeValues(ConnectionInterface $db): void
4644
{
4745
$db->createCommand()->insert(

tests/ConnectionTest.php

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
namespace Yiisoft\Db\Pgsql\Tests;
66

77
use PDO;
8-
use Throwable;
98
use Yiisoft\Db\Connection\ConnectionInterface;
10-
use Yiisoft\Db\Exception\Exception;
11-
use Yiisoft\Db\Exception\InvalidConfigException;
12-
use Yiisoft\Db\Exception\NotSupportedException;
9+
use Yiisoft\Db\Pgsql\Column\ColumnBuilder;
1310
use Yiisoft\Db\Pgsql\Column\ColumnFactory;
1411
use Yiisoft\Db\Pgsql\Connection;
1512
use Yiisoft\Db\Pgsql\Tests\Support\TestTrait;
@@ -19,17 +16,11 @@
1916

2017
/**
2118
* @group pgsql
22-
*
23-
* @psalm-suppress PropertyNotSetInConstructor
2419
*/
2520
final class ConnectionTest extends CommonConnectionTest
2621
{
2722
use TestTrait;
2823

29-
/**
30-
* @throws Exception
31-
* @throws InvalidConfigException
32-
*/
3324
public function testInitConnection(): void
3425
{
3526
$db = $this->getConnection();
@@ -42,10 +33,6 @@ public function testInitConnection(): void
4233
$db->close();
4334
}
4435

45-
/**
46-
* @throws Exception
47-
* @throws InvalidConfigException
48-
*/
4936
public function testSettingDefaultAttributes(): void
5037
{
5138
$db = $this->getConnection();
@@ -67,12 +54,6 @@ public function testSettingDefaultAttributes(): void
6754
$db->close();
6855
}
6956

70-
/**
71-
* @throws Exception
72-
* @throws InvalidConfigException
73-
* @throws NotSupportedException
74-
* @throws Throwable
75-
*/
7657
public function testTransactionIsolation(): void
7758
{
7859
$db = $this->getConnection();
@@ -103,11 +84,6 @@ public function testTransactionIsolation(): void
10384
$db->close();
10485
}
10586

106-
/**
107-
* @throws Exception
108-
* @throws InvalidConfigException
109-
* @throws Throwable
110-
*/
11187
public function testTransactionShortcutCustom(): void
11288
{
11389
$db = $this->getConnection(true);
@@ -137,6 +113,15 @@ static function (ConnectionInterface $db) {
137113
$db->close();
138114
}
139115

116+
public function getColumnBuilderClass(): void
117+
{
118+
$db = $this->getConnection();
119+
120+
$this->assertSame(ColumnBuilder::class, $db->getColumnBuilderClass());
121+
122+
$db->close();
123+
}
124+
140125
public function testGetColumnFactory(): void
141126
{
142127
$db = $this->getConnection();

0 commit comments

Comments
 (0)