Skip to content

Commit

Permalink
Revert "Remove methods with NotSupportedException"
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Aug 22, 2023
1 parent adfae64 commit d07b871
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 36 deletions.
19 changes: 19 additions & 0 deletions src/QueryBuilder/AbstractDMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ public function insert(string $table, QueryInterface|array $columns, array &$par
. (!empty($placeholders) ? ' VALUES (' . implode(', ', $placeholders) . ')' : ' ' . $values);
}

public function insertWithReturningPks(string $table, QueryInterface|array $columns, array &$params = []): string
{
throw new NotSupportedException(__METHOD__ . '() is not supported by this DBMS.');
}

public function resetSequence(string $table, int|string|null $value = null): string
{
throw new NotSupportedException(__METHOD__ . '() is not supported by this DBMS.');
}

public function update(string $table, array $columns, array|string $condition, array &$params = []): string
{
[$lines, $params] = $this->prepareUpdateSets($table, $columns, $params);
Expand All @@ -119,6 +129,15 @@ public function update(string $table, array $columns, array|string $condition, a
return $where === '' ? $sql : $sql . ' ' . $where;
}

public function upsert(
string $table,
QueryInterface|array $insertColumns,
bool|array $updateColumns,
array &$params
): string {
throw new NotSupportedException(__METHOD__ . ' is not supported by this DBMS.');
}

/**
* Prepare select-subQuery and field names for `INSERT INTO ... SELECT` SQL statement.
*
Expand Down
4 changes: 0 additions & 4 deletions tests/AbstractQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1918,8 +1918,6 @@ public function testResetSequenceNoAssociatedException(): void
$qb = $db->getQueryBuilder();

if ($db->getDriverName() === 'db') {
self::markTestSkipped('AbstractDMLQueryBuilder::resetSequence() was removed');

$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage(
'Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder::resetSequence() is not supported by this DBMS.'
Expand All @@ -1944,8 +1942,6 @@ public function testResetSequenceTableNoExistException(): void
$qb = $db->getQueryBuilder();

if ($db->getDriverName() === 'db') {
self::markTestSkipped('AbstractDMLQueryBuilder::resetSequence() was removed');

$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage(
'Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder::resetSequence() is not supported by this DBMS.'
Expand Down
4 changes: 0 additions & 4 deletions tests/Db/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,6 @@ public function testRenameTable(): void

public function testResetSequence(): void
{
self::markTestSkipped('AbstractDMLQueryBuilder::resetSequence() was removed');

$db = $this->getConnection();

$this->expectException(NotSupportedException::class);
Expand Down Expand Up @@ -702,8 +700,6 @@ public function testUpdate(): void

public function testUpsert(): void
{
self::markTestSkipped('AbstractDMLQueryBuilder::upsert() was removed');

$db = $this->getConnection();

$command = $db->createCommand();
Expand Down
8 changes: 0 additions & 8 deletions tests/Db/QueryBuilder/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ public function testInsertWithReturningPks(
string $expectedSQL,
array $expectedParams
): void {
self::markTestSkipped('AbstractDMLQueryBuilder::insertWithReturningPks() was removed');

$db = $this->getConnection();

$qb = $db->getQueryBuilder();
Expand All @@ -228,8 +226,6 @@ public function testInsertWithReturningPks(
*/
public function testResetSequence(): void
{
self::markTestSkipped('AbstractDMLQueryBuilder::resetSequence() was removed');

$db = $this->getConnection();

$qb = $db->getQueryBuilder();
Expand Down Expand Up @@ -278,8 +274,6 @@ public function testUpsert(
string|array $expectedSQL,
array $expectedParams
): void {
self::markTestSkipped('AbstractDMLQueryBuilder::upsert() was removed');

$db = $this->getConnection();

$actualParams = [];
Expand All @@ -300,8 +294,6 @@ public function testUpsertExecute(
array|QueryInterface $insertColumns,
array|bool $updateColumns
): void {
self::markTestSkipped('AbstractDMLQueryBuilder::upsert() was removed');

$db = $this->getConnection();

$this->expectException(NotSupportedException::class);
Expand Down
20 changes: 0 additions & 20 deletions tests/Support/Stub/DMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,8 @@

namespace Yiisoft\Db\Tests\Support\Stub;

use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder;

final class DMLQueryBuilder extends AbstractDMLQueryBuilder
{
public function insertWithReturningPks(string $table, QueryInterface|array $columns, array &$params = []): string
{
throw new NotSupportedException(__METHOD__ . '() is not supported by this DBMS.');
}

public function resetSequence(string $table, int|string|null $value = null): string
{
throw new NotSupportedException(__METHOD__ . '() is not supported by this DBMS.');
}

public function upsert(
string $table,
QueryInterface|array $insertColumns,
bool|array $updateColumns,
array &$params
): string {
throw new NotSupportedException(__METHOD__ . '() is not supported by this DBMS.');
}
}

0 comments on commit d07b871

Please sign in to comment.