Skip to content

Commit

Permalink
Show "error" on failed statements
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Feb 21, 2023
1 parent 371b1a3 commit a6dd039
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ protected function finalizeAddToDebug(
) : void {
$end = \microtime(true);
$rows = $this->mysqli->affected_rows;
$rows = $rows < 0 ? $rows . ' (failed)' : $rows;
$rows = $rows < 0 ? 'error' : $rows;
$this->debugCollector->addData([
'start' => $start,
'end' => $end,
Expand Down
8 changes: 7 additions & 1 deletion tests/Debug/DatabaseCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ public function testFinalizeAddToDebug() : void
$data = $this->collector->getData();
$data = $data[\array_key_last($data)];
self::assertSame('Foo Bar', $data['statement']);
self::assertSame('-1 (failed)', $data['rows']);
self::assertSame('error', $data['rows']);
$contents = $this->collector->getContents();
self::assertStringContainsString('error', $contents);
self::assertStringContainsString(
\htmlentities($data['description']),
$contents
);
}
}

0 comments on commit a6dd039

Please sign in to comment.