diff options
| author | Vladislav Poluhin | 2013-04-24 11:14:34 +0800 |
|---|---|---|
| committer | Vladislav Poluhin | 2013-04-24 11:14:34 +0800 |
| commit | 3d0467d9a4394c4b994a802e6e861ff2562dbb2b (patch) | |
| tree | 0b2aefc7b73ffbbe94e2505bbac01e31d99c2166 /debug_toolbar/utils/sql.py | |
| parent | e85dfe8ef37d6d99ee482fbd9ac3375ee86253ac (diff) | |
| download | django-debug-toolbar-3d0467d9a4394c4b994a802e6e861ff2562dbb2b.tar.bz2 | |
Got rid of the circular imports
Diffstat (limited to 'debug_toolbar/utils/sql.py')
| -rw-r--r-- | debug_toolbar/utils/sql.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/debug_toolbar/utils/sql.py b/debug_toolbar/utils/sql.py new file mode 100644 index 0000000..909edf7 --- /dev/null +++ b/debug_toolbar/utils/sql.py @@ -0,0 +1,15 @@ +import re +from debug_toolbar.utils import sqlparse +from debug_toolbar.utils.sqlparse.filters import BoldKeywordFilter + + +def reformat_sql(sql): + stack = sqlparse.engine.FilterStack() + stack.preprocess.append(BoldKeywordFilter()) # add our custom filter + stack.postprocess.append(sqlparse.filters.SerializerUnicode()) # tokens -> strings + return swap_fields(''.join(stack.run(sql))) + + +def swap_fields(sql): + return re.sub('SELECT</strong> (.*?) <strong>FROM', 'SELECT</strong> <a class="djDebugUncollapsed djDebugToggle" href="#">•••</a> ' + + '<a class="djDebugCollapsed djDebugToggle" href="#">\g<1></a> <strong>FROM', sql) |
