Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,11 @@ public function whereBetween($column, iterable $values, $boolean = 'and', $not =
/** @inheritdoc */
public function insert(array $values)
{
// Allow empty insert batch for consistency with Eloquent SQL
if ($values === []) {
return true;
}

// Since every insert gets treated like a batch insert, we will have to detect
// if the user is inserting a single document or an array of documents.
$batch = true;
Expand Down
6 changes: 6 additions & 0 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ public function testFind(): void
$this->assertEquals(35, $check->age);
}

public function testInsertEmpty(): void
{
$success = User::insert([]);
$this->assertTrue($success);
}

public function testGet(): void
{
User::insert([
Expand Down