Skip to content

Commit 252b721

Browse files
authored
Update test according to main PR (#260)
1 parent 0937af3 commit 252b721

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 2.0.0 under development
44

5+
- Enh #260: Support `Traversable` values for `DMLQueryBuilder::batchInsert()` method with empty columns (@Tigrov)
56
- Enh #255: Implement `SqlParser` and `ExpressionBuilder` driver classes (@Tigrov)
67

78
## 1.3.0 March 21, 2024

src/DMLQueryBuilder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ final class DMLQueryBuilder extends AbstractDMLQueryBuilder
3030
*/
3131
public function batchInsert(string $table, array $columns, iterable $rows, array &$params = []): string
3232
{
33+
if (!is_array($rows)) {
34+
$rows = $this->prepareTraversable($rows);
35+
}
36+
3337
if (empty($rows)) {
3438
return '';
3539
}

tests/CommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testAddDefaultValue(): void
6565
public function testBatchInsert(
6666
string $table,
6767
array $columns,
68-
array $values,
68+
iterable $values,
6969
string $expected,
7070
array $expectedParams = [],
7171
int $insertedRow = 1

tests/Provider/CommandProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public static function batchInsert(): array
6161
'empty columns and objects' => [
6262
':qp3' => '1',
6363
],
64-
'empty columns and Traversable' => [
64+
'empty columns and a Traversable value' => [
65+
':qp3' => '1',
66+
],
67+
'empty columns and Traversable values' => [
6568
':qp3' => '1',
6669
],
6770
];

0 commit comments

Comments
 (0)