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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 2.0.0 under development

- Enh #268: Rename `batchInsert()` to `insertBatch()` in `DMLQueryBuilder` and change parameters
from `$table, $columns, $rows` to `$table, $rows, $columns = []` (@Tigrov)
- Enh #260: Support `Traversable` values for `DMLQueryBuilder::batchInsert()` method with empty columns (@Tigrov)
- Enh #255: Implement `SqlParser` and `ExpressionBuilder` driver classes (@Tigrov)

Expand Down
21 changes: 1 addition & 20 deletions src/DMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

namespace Yiisoft\Db\Oracle;

use JsonException;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Query\QueryInterface;
Expand All @@ -22,13 +19,7 @@
*/
final class DMLQueryBuilder extends AbstractDMLQueryBuilder
{
/**
* @throws Exception
* @throws InvalidArgumentException
* @throws InvalidConfigException
* @throws NotSupportedException
*/
public function batchInsert(string $table, array $columns, iterable $rows, array &$params = []): string
public function insertBatch(string $table, iterable $rows, array $columns = [], array &$params = []): string
{
if (!is_array($rows)) {
$rows = $this->prepareTraversable($rows);
Expand Down Expand Up @@ -58,23 +49,13 @@ public function batchInsert(string $table, array $columns, iterable $rows, array
return 'INSERT ALL' . $tableAndColumns . implode($tableAndColumns, $values) . ' SELECT 1 FROM SYS.DUAL';
}

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

/**
* @link https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606
*
* @throws Exception
* @throws InvalidArgumentException
* @throws InvalidConfigException
* @throws JsonException
* @throws NotSupportedException
*/
public function upsert(
string $table,
Expand Down
4 changes: 2 additions & 2 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public function testAddDefaultValue(): void
*/
public function testBatchInsert(
string $table,
array $columns,
iterable $values,
array $columns,
string $expected,
array $expectedParams = [],
int $insertedRow = 1
): void {
parent::testBatchInsert($table, $columns, $values, $expected, $expectedParams, $insertedRow);
parent::testBatchInsert($table, $values, $columns, $expected, $expectedParams, $insertedRow);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Provider/CommandProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function batchInsert(): array
'table name with column name with brackets' => [
':qp3' => '0',
],
'batchInsert binds params from expression' => [
'binds params from expression' => [
':qp3' => '0',
],
'with associative values with different keys' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ public function testAlterColumn(): void
*/
public function testBatchInsert(
string $table,
array $columns,
iterable $rows,
array $columns,
string $expected,
array $expectedParams = [],
): void {
parent::testBatchInsert($table, $columns, $rows, $expected, $expectedParams);
parent::testBatchInsert($table, $rows, $columns, $expected, $expectedParams);
}

/**
Expand Down