From 0bed471bb06e3997d29bdc7dc8dec6a0e0c161a0 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Wed, 18 Feb 2009 15:50:52 +1100 Subject: Tidied up SQL formatting in SQL panel. Added formatting of "GROUP BY" and "HAVING", which now show up in trunk queries and could have shown up previously if manually patched into the QuerySet.query instance. Also indent joined tables a bit more underneath the "FROM" statement: they are sub-statements of "FROM". Signed-off-by: Rob Hudson --- debug_toolbar/panels/sql.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'debug_toolbar/panels/sql.py') diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py index 1aa42f7..b9800b8 100644 --- a/debug_toolbar/panels/sql.py +++ b/debug_toolbar/panels/sql.py @@ -75,9 +75,11 @@ def reformat_sql(sql): sql = sql.replace('SELECT ', 'SELECT\n\t') sql = sql.replace(' FROM ', '\nFROM\n\t') sql = sql.replace(' WHERE ', '\nWHERE\n\t') - sql = sql.replace(' INNER JOIN ', '\nINNER JOIN\n\t') - sql = sql.replace(' LEFT OUTER JOIN ', '\nLEFT OUTER JOIN\n\t') + sql = sql.replace(' INNER JOIN', '\n\tINNER JOIN') + sql = sql.replace(' LEFT OUTER JOIN' , '\n\tLEFT OUTER JOIN') sql = sql.replace(' ORDER BY ', '\nORDER BY\n\t') + sql = sql.replace(' HAVING ', '\nHAVING\n\t') + sql = sql.replace(' GROUP BY ', '\nGROUP BY\n\t') # Use Pygments to highlight SQL if it's available try: from pygments import highlight -- cgit v1.2.3