Skip to content

Commit

Permalink
DEBUG dump queries nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 31, 2021
1 parent 8e1283f commit 475987d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Schema/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function startQuery($sql, $params = null, $types = null): void
return;
}

if (class_exists('SqlFormatter')) { // requires optional "jdorn/sql-formatter" package
$sql = \SqlFormatter::format($sql, false);
}

echo "\n" . $sql . "\n" . (is_array($params) ? print_r(array_map(function ($v) {
if (is_string($v) && strlen($v) > 4096) {
$v = '*long string* (length: ' . strlen($v) . ' bytes, sha256: ' . hash('sha256', $v) . ')';
Expand Down

0 comments on commit 475987d

Please sign in to comment.