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 @@ -61,6 +61,7 @@
- New #357, #363: Implement `ArrayMergeBuilder`, `LongestBuilder` and `ShortestBuilder` classes (@Tigrov)
- Enh #360: Refactor `DMLQueryBuilder::upsert()` method (@Tigrov)
- Chg #365: Update expression namespaces according to changes in `yiisoft/db` package (@Tigrov)
- Enh #359: Update `DMLQueryBuilder::update()` method to adapt changes in `yiisoft/db` (@rustamwin)

## 1.3.0 March 21, 2024

Expand Down
14 changes: 14 additions & 0 deletions src/DMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use InvalidArgumentException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder;

Expand Down Expand Up @@ -54,6 +55,19 @@ public function insertReturningPks(string $table, array|QueryInterface $columns,
throw new NotSupportedException(__METHOD__ . ' is not supported by Oracle.');
}

public function update(
string $table,
array $columns,
array|string|ExpressionInterface $condition,
array|string|ExpressionInterface|null $from = null,
array &$params = []
): string {
if ($from !== null) {
throw new NotSupportedException('Oracle does not support FROM clause in UPDATE statement.');
}
return parent::update($table, $columns, $condition, null, $params);
}

/**
* @link https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606
*/
Expand Down
10 changes: 8 additions & 2 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Yiisoft\Db\Constraint\Index;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Oracle\Column\ColumnBuilder;
use Yiisoft\Db\Oracle\IndexType;
use Yiisoft\Db\Oracle\Tests\Provider\CommandProvider;
Expand Down Expand Up @@ -483,12 +484,17 @@ public function testNoTablenameReplacement(): void
public function testUpdate(
string $table,
array $columns,
array|string $conditions,
array|ExpressionInterface|string $conditions,
array|ExpressionInterface|string|null $from,
array $params,
array $expectedValues,
int $expectedCount,
): void {
parent::testUpdate($table, $columns, $conditions, $params, $expectedValues, $expectedCount);
if ($from !== null) {
$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage('Oracle does not support FROM clause in UPDATE statement.');
}
parent::testUpdate($table, $columns, $conditions, $from, $params, $expectedValues, $expectedCount);
}

#[DataProviderExternal(CommandProvider::class, 'upsert')]
Expand Down
9 changes: 7 additions & 2 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,17 @@ public function testSelectExists(): void
public function testUpdate(
string $table,
array $columns,
array|string $condition,
array|ExpressionInterface|string $condition,
array|ExpressionInterface|string|null $from,
array $params,
string $expectedSql,
array $expectedParams = [],
): void {
parent::testUpdate($table, $columns, $condition, $params, $expectedSql, $expectedParams);
if ($from !== null) {
$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage('Oracle does not support FROM clause in UPDATE statement.');
}
parent::testUpdate($table, $columns, $condition, $from, $params, $expectedSql, $expectedParams);
}

#[DataProviderExternal(QueryBuilderProvider::class, 'upsert')]
Expand Down
Loading