Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- Enh #371, #374: Adapt to conditions refactoring in `yiisoft/db` package (@vjik)
- Enh #377: Remove `TableSchema` class and refactor `Schema` class (@Tigrov)
- Enh #380: Support column's collation (@Tigrov)
- New #385: Add `Connection::getColumnBuilderClass()` method (@Tigrov)

## 1.2.0 March 21, 2024

Expand Down
6 changes: 6 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Yiisoft\Db\Schema\Quoter;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\SchemaInterface;
use Yiisoft\Db\Sqlite\Column\ColumnBuilder;
use Yiisoft\Db\Sqlite\Column\ColumnFactory;

use function str_starts_with;
Expand Down Expand Up @@ -58,6 +59,11 @@ public function createTransaction(): Transaction
return new Transaction($this);
}

public function getColumnBuilderClass(): string
{
return ColumnBuilder::class;
}

public function getColumnFactory(): ColumnFactoryInterface
{
return $this->columnFactory ??= new ColumnFactory();
Expand Down
6 changes: 0 additions & 6 deletions tests/ColumnBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Yiisoft\Db\Sqlite\Tests;

use Yiisoft\Db\Sqlite\Column\ColumnBuilder;
use Yiisoft\Db\Sqlite\Tests\Support\TestTrait;
use Yiisoft\Db\Tests\AbstractColumnBuilderTest;

Expand All @@ -14,9 +13,4 @@
class ColumnBuilderTest extends AbstractColumnBuilderTest
{
use TestTrait;

public function getColumnBuilderClass(): string
{
return ColumnBuilder::class;
}
}
3 changes: 0 additions & 3 deletions tests/ColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Yiisoft\Db\Schema\Column\IntegerColumn;
use Yiisoft\Db\Schema\Column\JsonColumn;
use Yiisoft\Db\Schema\Column\StringColumn;
use Yiisoft\Db\Sqlite\Column\ColumnBuilder;
use Yiisoft\Db\Sqlite\Tests\Support\TestTrait;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\Tests\Common\CommonColumnTest;
Expand All @@ -30,8 +29,6 @@ final class ColumnTest extends CommonColumnTest
{
use TestTrait;

protected const COLUMN_BUILDER = ColumnBuilder::class;

protected function insertTypeValues(ConnectionInterface $db): void
{
$command = $db->createCommand();
Expand Down
38 changes: 10 additions & 28 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Throwable;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Profiler\ProfilerInterface;
use Yiisoft\Db\Sqlite\Column\ColumnBuilder;
use Yiisoft\Db\Sqlite\Column\ColumnFactory;
use Yiisoft\Db\Sqlite\Connection;
use Yiisoft\Db\Sqlite\Tests\Support\TestTrait;
Expand All @@ -23,18 +21,11 @@

/**
* @group sqlite
*
* @psalm-suppress PropertyNotSetInConstructor
*/
final class ConnectionTest extends CommonConnectionTest
{
use TestTrait;

/**
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
public function testExceptionContainsRawQuery(): void
{
$db = $this->getConnection();
Expand Down Expand Up @@ -73,10 +64,6 @@ public function testExceptionContainsRawQuery(): void
$this->runExceptionTest($db);
}

/**
* @throws Exception
* @throws InvalidConfigException
*/
public function testSettingDefaultAttributes(): void
{
$db = $this->getConnection();
Expand All @@ -86,12 +73,6 @@ public function testSettingDefaultAttributes(): void
$db->close();
}

/**
* @throws Exception
* @throws InvalidConfigException
* @throws NotSupportedException
* @throws Throwable
*/
public function testTransactionIsolation(): void
{
$db = $this->getConnection(true);
Expand All @@ -106,11 +87,6 @@ public function testTransactionIsolation(): void
$this->assertTrue(true);
}

/**
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
public function testTransactionShortcutCustom(): void
{
$db = $this->getConnection(true);
Expand Down Expand Up @@ -143,9 +119,6 @@ protected function getLogger(): LoggerInterface|MockObject
return $this->createMock(LoggerInterface::class);
}

/**
* @throws Throwable
*/
private function runExceptionTest(ConnectionInterface $db): void
{
$thrown = false;
Expand Down Expand Up @@ -189,6 +162,15 @@ private function createProfiler(): ProfilerInterface
return $this->createMock(ProfilerInterface::class);
}

public function getColumnBuilderClass(): void
{
$db = $this->getConnection();

$this->assertSame(ColumnBuilder::class, $db->getColumnBuilderClass());

$db->close();
}

public function testGetColumnFactory(): void
{
$db = $this->getConnection();
Expand Down
Loading