Skip to content

Commit 6b40636

Browse files
authored
Add Connection::getColumnBuilderClass() (#421)
1 parent 9761aea commit 6b40636

File tree

5 files changed

+17
-33
lines changed

5 files changed

+17
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
- Enh #407, #408, #411: Adapt to conditions refactoring in `yiisoft/db` package (@vjik)
5050
- Enh #414: Remove `TableSchema` class and refactor `Schema` class (@Tigrov)
5151
- Enh #415: Support column's collation (@Tigrov)
52+
- New #421: Add `Connection::getColumnBuilderClass()` method (@Tigrov)
5253

5354
## 1.2.0 March 21, 2024
5455

src/Connection.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Yiisoft\Db\Connection\ServerInfoInterface;
1010
use Yiisoft\Db\Driver\Pdo\AbstractPdoConnection;
1111
use Yiisoft\Db\Driver\Pdo\PdoCommandInterface;
12+
use Yiisoft\Db\Mysql\Column\ColumnBuilder;
1213
use Yiisoft\Db\Mysql\Column\ColumnFactory;
1314
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
1415
use Yiisoft\Db\Schema\Column\ColumnFactoryInterface;
@@ -66,6 +67,11 @@ public function createTransaction(): TransactionInterface
6667
return new Transaction($this);
6768
}
6869

70+
public function getColumnBuilderClass(): string
71+
{
72+
return ColumnBuilder::class;
73+
}
74+
6975
public function getColumnFactory(): ColumnFactoryInterface
7076
{
7177
return $this->columnFactory ??= new ColumnFactory();

tests/ColumnBuilderTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Yiisoft\Db\Mysql\Tests;
66

77
use PHPUnit\Framework\Attributes\DataProviderExternal;
8-
use Yiisoft\Db\Mysql\Column\ColumnBuilder;
98
use Yiisoft\Db\Mysql\Tests\Provider\ColumnBuilderProvider;
109
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
1110
use Yiisoft\Db\Tests\AbstractColumnBuilderTest;
@@ -17,11 +16,6 @@ class ColumnBuilderTest extends AbstractColumnBuilderTest
1716
{
1817
use TestTrait;
1918

20-
public function getColumnBuilderClass(): string
21-
{
22-
return ColumnBuilder::class;
23-
}
24-
2519
#[DataProviderExternal(ColumnBuilderProvider::class, 'buildingMethods')]
2620
public function testBuildingMethods(
2721
string $buildingMethod,

tests/ColumnTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ final class ColumnTest extends CommonColumnTest
3232
{
3333
use TestTrait;
3434

35-
protected const COLUMN_BUILDER = ColumnBuilder::class;
36-
3735
protected function insertTypeValues(ConnectionInterface $db): void
3836
{
3937
$db->createCommand()->insert(

tests/ConnectionTest.php

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

77
use PDO;
8-
use Throwable;
98
use Yiisoft\Db\Connection\ConnectionInterface;
10-
use Yiisoft\Db\Exception\Exception;
119
use Yiisoft\Db\Exception\IntegrityException;
12-
use Yiisoft\Db\Exception\InvalidConfigException;
13-
use Yiisoft\Db\Exception\NotSupportedException;
10+
use Yiisoft\Db\Mysql\Column\ColumnBuilder;
1411
use Yiisoft\Db\Mysql\Column\ColumnFactory;
1512
use Yiisoft\Db\Mysql\Connection;
1613
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
@@ -20,17 +17,11 @@
2017

2118
/**
2219
* @group mysql
23-
*
24-
* @psalm-suppress PropertyNotSetInConstructor
2520
*/
2621
final class ConnectionTest extends CommonConnectionTest
2722
{
2823
use TestTrait;
2924

30-
/**
31-
* @throws Exception
32-
* @throws InvalidConfigException
33-
*/
3425
public function testInitConnection(): void
3526
{
3627
$db = $this->getConnection();
@@ -47,10 +38,6 @@ public function testInitConnection(): void
4738
$db->close();
4839
}
4940

50-
/**
51-
* @throws Exception
52-
* @throws InvalidConfigException
53-
*/
5441
public function testSettingDefaultAttributes(): void
5542
{
5643
$db = $this->getConnection();
@@ -72,12 +59,6 @@ public function testSettingDefaultAttributes(): void
7259
$db->close();
7360
}
7461

75-
/**
76-
* @throws Exception
77-
* @throws InvalidConfigException
78-
* @throws NotSupportedException
79-
* @throws Throwable
80-
*/
8162
public function testTransactionIsolation(): void
8263
{
8364
$db = $this->getConnection(true);
@@ -100,11 +81,6 @@ public function testTransactionIsolation(): void
10081
$db->close();
10182
}
10283

103-
/**
104-
* @throws Exception
105-
* @throws InvalidConfigException
106-
* @throws Throwable
107-
*/
10884
public function testTransactionShortcutCustom(): void
10985
{
11086
$db = $this->getConnection(true);
@@ -162,6 +138,15 @@ public function testNotRestartConnectionOnTimeoutInTransaction(): void
162138
$db->close();
163139
}
164140

141+
public function getColumnBuilderClass(): void
142+
{
143+
$db = $this->getConnection();
144+
145+
$this->assertSame(ColumnBuilder::class, $db->getColumnBuilderClass());
146+
147+
$db->close();
148+
}
149+
165150
public function testGetColumnFactory(): void
166151
{
167152
$db = $this->getConnection();

0 commit comments

Comments
 (0)