aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/utils/sql.py
diff options
context:
space:
mode:
Diffstat (limited to 'debug_toolbar/utils/sql.py')
-rw-r--r--debug_toolbar/utils/sql.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/debug_toolbar/utils/sql.py b/debug_toolbar/utils/sql.py
index 909edf7..5de7da5 100644
--- a/debug_toolbar/utils/sql.py
+++ b/debug_toolbar/utils/sql.py
@@ -1,6 +1,22 @@
import re
-from debug_toolbar.utils import sqlparse
-from debug_toolbar.utils.sqlparse.filters import BoldKeywordFilter
+
+from django.utils.html import escape
+
+import sqlparse
+from sqlparse import tokens as T
+
+
+class BoldKeywordFilter:
+ """sqlparse filter to bold SQL keywords"""
+ def process(self, stack, stream):
+ """Process the token stream"""
+ for token_type, value in stream:
+ is_keyword = token_type in T.Keyword
+ if is_keyword:
+ yield T.Text, '<strong>'
+ yield token_type, escape(value)
+ if is_keyword:
+ yield T.Text, '</strong>'
def reformat_sql(sql):