Skip to content

Commit 4c757a7

Browse files
committed
Use HtmlHighlighter for SQL formatting with proper color output
The default Doctrine SqlFormatter uses HtmlHighlighter which produces colored HTML output with pre tags, matching the old jdorn/sql-formatter behavior. NullHighlighter only produces plain text without formatting.
1 parent de66dd0 commit 4c757a7

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

plugins/Sandbox/src/Controller/GeoExamplesController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Cake\Core\Configure;
66
use Cake\Database\Driver\Mysql;
77
use Cake\Utility\Text;
8-
use Doctrine\SqlFormatter\NullHighlighter;
98
use Doctrine\SqlFormatter\SqlFormatter;
109
use Exception;
1110
use Geo\Exception\InconclusiveException;
@@ -247,7 +246,7 @@ public function filter() {
247246
->contain(['Countries'])
248247
->limit(10);
249248
$sqlQuery = (string)$query;
250-
$sqlQueryFormatted = (new SqlFormatter(new NullHighlighter()))->format($sqlQuery);
249+
$sqlQueryFormatted = (new SqlFormatter())->format($sqlQuery);
251250

252251
// Get EXPLAIN output for the query
253252
if ($spatialAvailable && $this->request->getQuery('spatial')) {

plugins/Sandbox/src/Controller/ToolsExamplesController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Sandbox\Controller;
44

55
use Cake\Event\EventInterface;
6-
use Doctrine\SqlFormatter\NullHighlighter;
76
use Doctrine\SqlFormatter\SqlFormatter;
87
use RuntimeException;
98
use Sandbox\Model\Entity\BitmaskedRecord;
@@ -196,7 +195,7 @@ public function bitmaskSearch() {
196195

197196
$query = $bitmaskedRecordsTable->find('search', search: $this->request->getQuery());
198197
$sql = (string)$query;
199-
$sqlFormatted = (new SqlFormatter(new NullHighlighter()))->format($sql);
198+
$sqlFormatted = (new SqlFormatter())->format($sql);
200199

201200
$bitmaskedRecords = $this->paginate($query);
202201

plugins/Sandbox/templates/ToolsExamples/bitmask_search.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,5 @@
6565

6666
<h3>SQL query</h3>
6767
For example/demo purposes here the query it runs as per your filter selection above:
68-
<div>
69-
<?php echo $sqlFormatted; ?>
70-
</div>
68+
<?php echo $sqlFormatted; ?>
7169

0 commit comments

Comments
 (0)