Skip to content

Commit ba2ddc1

Browse files
committed
Use Connection::$columnFactory property
1 parent 17ee629 commit ba2ddc1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function createTransaction(): TransactionInterface
4848

4949
public function getColumnFactory(): ColumnFactoryInterface
5050
{
51-
return new ColumnFactory();
51+
return $this->columnFactory ??= new ColumnFactory();
5252
}
5353

5454
public function getLastInsertID(?string $sequenceName = null): string

tests/ConnectionTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
use Yiisoft\Db\Exception\InvalidConfigException;
1212
use Yiisoft\Db\Exception\NotSupportedException;
1313
use Yiisoft\Db\Pgsql\Column\ColumnFactory;
14+
use Yiisoft\Db\Pgsql\Connection;
1415
use Yiisoft\Db\Pgsql\Tests\Support\TestTrait;
1516
use Yiisoft\Db\Tests\Common\CommonConnectionTest;
17+
use Yiisoft\Db\Tests\Support\DbHelper;
1618
use Yiisoft\Db\Transaction\TransactionInterface;
1719

1820
/**
@@ -143,4 +145,15 @@ public function testGetColumnFactory(): void
143145

144146
$db->close();
145147
}
148+
149+
public function testUserDefinedColumnFactory(): void
150+
{
151+
$columnFactory = new ColumnFactory();
152+
153+
$db = new Connection($this->getDriver(), DbHelper::getSchemaCache(), $columnFactory);
154+
155+
$this->assertSame($columnFactory, $db->getColumnFactory());
156+
157+
$db->close();
158+
}
146159
}

0 commit comments

Comments
 (0)