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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Changed

Fixed
- `Schema\Grammar::compileAdd()` `Schema\Grammar::compileChange()` `Schema\Grammar::compileChange()` now create separate statements (#159)
- `Connection::runDdlBatch()` with empty statement now return an empty array instead of throwing an error (#169)

# v6.1.2 (2024-01-16)

Expand Down
4 changes: 4 additions & 0 deletions src/Concerns/ManagesDataDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function runDdls(array $ddls): LongRunningOperation
*/
public function runDdlBatch(array $statements): mixed
{
if (count($statements) === 0) {
return [];
}

$start = microtime(true);

$result = $this->waitForOperation(
Expand Down
13 changes: 13 additions & 0 deletions tests/Concerns/ManagesDataDefinitionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ public function test_runDdlBatch(): void
Event::assertDispatchedTimes(QueryExecuted::class, 1);
}

public function test_runDdlBatch_with_empty_statement(): void
{
$events = Event::fake([QueryExecuted::class]);
$conn = $this->getDefaultConnection();
$conn->setEventDispatcher($events);
$conn->enableQueryLog();
$result = $conn->runDdlBatch([]);

$this->assertSame([], $result);
$this->assertCount(0, $conn->getQueryLog());
Event::assertNotDispatched(QueryExecuted::class);
}

public function test_createDatabase_with_statements(): void
{
$events = Event::fake([QueryExecuted::class]);
Expand Down