Skip to content

Commit 17a1674

Browse files
committed
Use Connection::$columnFactory property
1 parent 1583b07 commit 17a1674

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Connection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function createTransaction(): TransactionInterface
6767

6868
public function getColumnFactory(): ColumnFactoryInterface
6969
{
70-
return new ColumnFactory();
70+
return $this->columnFactory ??= new ColumnFactory();
7171
}
7272

7373
public function getQueryBuilder(): QueryBuilderInterface

tests/ConnectionTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
use Yiisoft\Db\Exception\InvalidConfigException;
1313
use Yiisoft\Db\Exception\NotSupportedException;
1414
use Yiisoft\Db\Mysql\Column\ColumnFactory;
15+
use Yiisoft\Db\Mysql\Connection;
1516
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
1617
use Yiisoft\Db\Tests\Common\CommonConnectionTest;
18+
use Yiisoft\Db\Tests\Support\DbHelper;
1719
use Yiisoft\Db\Transaction\TransactionInterface;
1820

1921
/**
@@ -168,4 +170,15 @@ public function testGetColumnFactory(): void
168170

169171
$db->close();
170172
}
173+
174+
public function testUserDefinedColumnFactory(): void
175+
{
176+
$columnFactory = new ColumnFactory();
177+
178+
$db = new Connection($this->getDriver(), DbHelper::getSchemaCache(), $columnFactory);
179+
180+
$this->assertSame($columnFactory, $db->getColumnFactory());
181+
182+
$db->close();
183+
}
171184
}

0 commit comments

Comments
 (0)