Skip to content

Commit daba0ca

Browse files
committed
Fix formatting of pre-formatted text and highlight of 'order by' and operators like 'in()'
1 parent dbab670 commit daba0ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/DatabaseLogger.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ private function prepareLogEntry($query, $time, $params, $trace = false)
171171

172172
private function formatQuery($query)
173173
{
174-
$query = preg_replace('/ (((left|right|outer|inner) )?join|where) /i', "\n $1 ", $query);
175-
$query = preg_replace('/ (order by|limit|having) /i', "\n $1 ", $query);
176-
$query = preg_replace('/ (union( (all|distinct))?) /i', "\n$1\n", $query);
174+
$query = preg_replace('/(?<!\s) (((left|right|outer|inner) )?join|where) /i', "\n $1 ", $query);
175+
$query = preg_replace('/(?<!\s) (order by|limit|having) /i', "\n $1 ", $query);
176+
$query = preg_replace('/(?<!\s) (union( (all|distinct))?) /i', "\n$1\n", $query);
177177

178178
$query = preg_replace(
179179
'/(?<=^|\s|\()(select|set|from|explain|update|insert|replace|left|right|outer|inner|join|where|order by|'
180180
. 'limit|as|and|or|having|union|all|distinct|on|is|not|null|true|false|desc|asc|between|in)'
181-
. '(?=$|\s|\)|,)/ix', "<b>$1</b>", $query
181+
. '(?=$|\s|\)|\(|,)/i', "<b>$1</b>", $query
182182
);
183183

184184
return $query;

0 commit comments

Comments
 (0)