From 8d9ba115825e442aa4fc9ec7b8f38a830665d772 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sun, 28 Apr 2024 11:13:05 +0700 Subject: [PATCH 1/3] Update according to the main PR --- src/DMLQueryBuilder.php | 18 +----------------- tests/CommandTest.php | 4 ++-- tests/Provider/CommandProvider.php | 2 +- tests/QueryBuilderTest.php | 4 ++-- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/DMLQueryBuilder.php b/src/DMLQueryBuilder.php index c1b57e1..4e50401 100644 --- a/src/DMLQueryBuilder.php +++ b/src/DMLQueryBuilder.php @@ -22,13 +22,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 +52,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 +59,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 6f6a39b..e48793a 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 7945e39..32353a9 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 1fa8f2c..e973c64 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); } /** From 1f82849da871d703dae28a16d17db5e29bcb8912 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sun, 28 Apr 2024 05:20:49 +0000 Subject: [PATCH 2/3] Apply fixes from StyleCI --- src/DMLQueryBuilder.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/DMLQueryBuilder.php b/src/DMLQueryBuilder.php index 4e50401..a04164f 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; From 11ac48cc2438864d16a17d1767371fd29e92ae12 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sun, 5 May 2024 15:10:01 +0700 Subject: [PATCH 3/3] Add line to CHANGELOG.md [skip ci] --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59bbd8c..b155a23 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)