Skip to content

Commit

Permalink
Update test according to main PR (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Apr 27, 2024
1 parent 0937af3 commit 252b721
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

## 2.0.0 under development

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

## 1.3.0 March 21, 2024
Expand Down
4 changes: 4 additions & 0 deletions src/DMLQueryBuilder.php
Expand Up @@ -30,6 +30,10 @@ final class DMLQueryBuilder extends AbstractDMLQueryBuilder
*/
public function batchInsert(string $table, array $columns, iterable $rows, array &$params = []): string
{
if (!is_array($rows)) {
$rows = $this->prepareTraversable($rows);
}

if (empty($rows)) {
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion tests/CommandTest.php
Expand Up @@ -65,7 +65,7 @@ public function testAddDefaultValue(): void
public function testBatchInsert(
string $table,
array $columns,
array $values,
iterable $values,
string $expected,
array $expectedParams = [],
int $insertedRow = 1
Expand Down
5 changes: 4 additions & 1 deletion tests/Provider/CommandProvider.php
Expand Up @@ -61,7 +61,10 @@ public static function batchInsert(): array
'empty columns and objects' => [
':qp3' => '1',
],
'empty columns and Traversable' => [
'empty columns and a Traversable value' => [
':qp3' => '1',
],
'empty columns and Traversable values' => [
':qp3' => '1',
],
];
Expand Down

0 comments on commit 252b721

Please sign in to comment.