diff --git a/CHANGELOG.md b/CHANGELOG.md index 59bbd8c9..b155a231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/DMLQueryBuilder.php b/src/DMLQueryBuilder.php index c1b57e10..a04164fe 100644 --- a/src/DMLQueryBuilder.php +++ b/src/DMLQueryBuilder.php @@ -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; @@ -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); @@ -58,10 +49,6 @@ 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.'); @@ -69,12 +56,6 @@ public function insertWithReturningPks(string $table, QueryInterface|array $colu /** * @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, diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 6f6a39b2..e48793ab 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -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); } /** diff --git a/tests/Provider/CommandProvider.php b/tests/Provider/CommandProvider.php index 7945e398..32353a98 100644 --- a/tests/Provider/CommandProvider.php +++ b/tests/Provider/CommandProvider.php @@ -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' => [ diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index 1fa8f2c9..e973c649 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -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); } /**