Skip to content

Commit a777933

Browse files
authored
Update according to the main PR (#268)
1 parent 4f32162 commit a777933

File tree

5 files changed

+8
-25
lines changed

5 files changed

+8
-25
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## 2.0.0 under development
44

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

src/DMLQueryBuilder.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
namespace Yiisoft\Db\Oracle;
66

7-
use JsonException;
8-
use Yiisoft\Db\Exception\Exception;
97
use Yiisoft\Db\Exception\InvalidArgumentException;
10-
use Yiisoft\Db\Exception\InvalidConfigException;
118
use Yiisoft\Db\Exception\NotSupportedException;
129
use Yiisoft\Db\Expression\Expression;
1310
use Yiisoft\Db\Query\QueryInterface;
@@ -22,13 +19,7 @@
2219
*/
2320
final class DMLQueryBuilder extends AbstractDMLQueryBuilder
2421
{
25-
/**
26-
* @throws Exception
27-
* @throws InvalidArgumentException
28-
* @throws InvalidConfigException
29-
* @throws NotSupportedException
30-
*/
31-
public function batchInsert(string $table, array $columns, iterable $rows, array &$params = []): string
22+
public function insertBatch(string $table, iterable $rows, array $columns = [], array &$params = []): string
3223
{
3324
if (!is_array($rows)) {
3425
$rows = $this->prepareTraversable($rows);
@@ -58,23 +49,13 @@ public function batchInsert(string $table, array $columns, iterable $rows, array
5849
return 'INSERT ALL' . $tableAndColumns . implode($tableAndColumns, $values) . ' SELECT 1 FROM SYS.DUAL';
5950
}
6051

61-
/**
62-
* @throws Exception
63-
* @throws NotSupportedException
64-
*/
6552
public function insertWithReturningPks(string $table, QueryInterface|array $columns, array &$params = []): string
6653
{
6754
throw new NotSupportedException(__METHOD__ . ' is not supported by Oracle.');
6855
}
6956

7057
/**
7158
* @link https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606
72-
*
73-
* @throws Exception
74-
* @throws InvalidArgumentException
75-
* @throws InvalidConfigException
76-
* @throws JsonException
77-
* @throws NotSupportedException
7859
*/
7960
public function upsert(
8061
string $table,

tests/CommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ public function testAddDefaultValue(): void
6464
*/
6565
public function testBatchInsert(
6666
string $table,
67-
array $columns,
6867
iterable $values,
68+
array $columns,
6969
string $expected,
7070
array $expectedParams = [],
7171
int $insertedRow = 1
7272
): void {
73-
parent::testBatchInsert($table, $columns, $values, $expected, $expectedParams, $insertedRow);
73+
parent::testBatchInsert($table, $values, $columns, $expected, $expectedParams, $insertedRow);
7474
}
7575

7676
/**

tests/Provider/CommandProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function batchInsert(): array
3737
'table name with column name with brackets' => [
3838
':qp3' => '0',
3939
],
40-
'batchInsert binds params from expression' => [
40+
'binds params from expression' => [
4141
':qp3' => '0',
4242
],
4343
'with associative values with different keys' => [

tests/QueryBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ public function testAlterColumn(): void
126126
*/
127127
public function testBatchInsert(
128128
string $table,
129-
array $columns,
130129
iterable $rows,
130+
array $columns,
131131
string $expected,
132132
array $expectedParams = [],
133133
): void {
134-
parent::testBatchInsert($table, $columns, $rows, $expected, $expectedParams);
134+
parent::testBatchInsert($table, $rows, $columns, $expected, $expectedParams);
135135
}
136136

137137
/**

0 commit comments

Comments
 (0)