diff --git a/silk/migrations/0009_sqlquery_query_structure.py b/silk/migrations/0009_sqlquery_query_structure.py new file mode 100644 index 00000000..46201a22 --- /dev/null +++ b/silk/migrations/0009_sqlquery_query_structure.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.16 on 2022-10-21 15:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('silk', '0008_sqlquery_analysis'), + ] + + operations = [ + migrations.AddField( + model_name='sqlquery', + name='query_structure', + field=models.TextField(default=''), + ), + ] diff --git a/silk/models.py b/silk/models.py index e7490d5c..ad4fe0fe 100644 --- a/silk/models.py +++ b/silk/models.py @@ -237,6 +237,7 @@ def bulk_create(self, *args, **kwargs): class SQLQuery(models.Model): query = TextField() + query_structure = TextField(default='') start_time = DateTimeField(null=True, blank=True, default=timezone.now) end_time = DateTimeField(null=True, blank=True) time_taken = FloatField(blank=True, null=True) diff --git a/silk/sql.py b/silk/sql.py index 197a999d..5a8feec7 100644 --- a/silk/sql.py +++ b/silk/sql.py @@ -81,6 +81,7 @@ def execute_sql(self, *args, **kwargs): if _should_wrap(sql_query): query_dict = { 'query': sql_query, + 'query_structure': q, 'start_time': timezone.now(), 'traceback': tb } diff --git a/silk/templates/silk/sql.html b/silk/templates/silk/sql.html index 2b5b970d..e59bb03b 100644 --- a/silk/templates/silk/sql.html +++ b/silk/templates/silk/sql.html @@ -41,7 +41,7 @@ height: 20px; } - tr.data-row:hover { + tr.data-row:hover, tr.data-row.highlight { background-color: rgb(51, 51, 68); color: white; cursor: pointer; @@ -108,10 +108,14 @@