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 @@ -53,6 +53,7 @@
- Enh #380: Remove support dots in table names (@Tigrov)
- Enh #383: Refactor `TableSchema` and `Schema` classes (@Tigrov)
- Enh #386: Support column's collation (@Tigrov)
- New #391: 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 @@ -6,6 +6,7 @@

use Yiisoft\Db\Driver\Pdo\AbstractPdoConnection;
use Yiisoft\Db\Driver\Pdo\PdoCommandInterface;
use Yiisoft\Db\Mssql\Column\ColumnBuilder;
use Yiisoft\Db\Mssql\Column\ColumnFactory;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Schema\Column\ColumnFactoryInterface;
Expand Down Expand Up @@ -44,6 +45,11 @@ public function createTransaction(): TransactionInterface
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 @@ -5,7 +5,6 @@
namespace Yiisoft\Db\Mssql\Tests;

use PHPUnit\Framework\Attributes\DataProviderExternal;
use Yiisoft\Db\Mssql\Column\ColumnBuilder;
use Yiisoft\Db\Mssql\Tests\Provider\ColumnBuilderProvider;
use Yiisoft\Db\Mssql\Tests\Support\TestTrait;
use Yiisoft\Db\Tests\AbstractColumnBuilderTest;
Expand All @@ -17,11 +16,6 @@ class ColumnBuilderTest extends AbstractColumnBuilderTest
{
use TestTrait;

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

#[DataProviderExternal(ColumnBuilderProvider::class, 'buildingMethods')]
public function testBuildingMethods(
string $buildingMethod,
Expand Down
3 changes: 0 additions & 3 deletions tests/ColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Expression\Param;
use Yiisoft\Db\Mssql\Column\BinaryColumn;
use Yiisoft\Db\Mssql\Column\ColumnBuilder;
use Yiisoft\Db\Mssql\Tests\Provider\ColumnProvider;
use Yiisoft\Db\Mssql\Tests\Support\TestTrait;
use Yiisoft\Db\Schema\Column\BooleanColumn;
Expand All @@ -33,8 +32,6 @@ final class ColumnTest extends CommonColumnTest
{
use TestTrait;

protected const COLUMN_BUILDER = ColumnBuilder::class;

protected function insertTypeValues(ConnectionInterface $db): void
{
$db->createCommand()->insert(
Expand Down
31 changes: 10 additions & 21 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
namespace Yiisoft\Db\Mssql\Tests;

use PDO;
use Throwable;
use Yiisoft\Db\Driver\Pdo\PdoConnectionInterface;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Mssql\Column\ColumnBuilder;
use Yiisoft\Db\Mssql\Column\ColumnFactory;
use Yiisoft\Db\Mssql\Connection;
use Yiisoft\Db\Mssql\Tests\Support\TestTrait;
Expand All @@ -19,19 +16,11 @@

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

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

/**
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
public function testTransactionShortcutCustom(): void
{
$db = $this->getConnection();
Expand All @@ -80,17 +64,22 @@ static function (PdoConnectionInterface $db): bool {
$this->assertSame('1', $profilesCount, 'profile should be inserted in transaction shortcut');
}

/**
* @throws Exception
* @throws InvalidConfigException
*/
public function testSettingDefaultAttributes(): void
{
$db = $this->getConnection();

$this->assertSame(PDO::ERRMODE_EXCEPTION, $db->getActivePDO()?->getAttribute(PDO::ATTR_ERRMODE));
}

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

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

$db->close();
}

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