diff --git a/silk/migrations/0008_sqlquery_query_structure.py b/silk/migrations/0008_sqlquery_query_structure.py new file mode 100644 index 00000000..32dd73a6 --- /dev/null +++ b/silk/migrations/0008_sqlquery_query_structure.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1 on 2020-08-21 19:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('silk', '0007_sqlquery_identifier'), + ] + + operations = [ + migrations.AddField( + model_name='sqlquery', + name='query_structure', + field=models.TextField(default=''), + preserve_default=False, + ), + ] diff --git a/silk/models.py b/silk/models.py index f69c7d4d..01581b23 100644 --- a/silk/models.py +++ b/silk/models.py @@ -232,6 +232,7 @@ def bulk_create(self, *args, **kwargs): class SQLQuery(models.Model): query = TextField() + query_structure = TextField() 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 576762e5..8903063d 100644 --- a/silk/sql.py +++ b/silk/sql.py @@ -41,6 +41,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..48deb161 100644 --- a/silk/templates/silk/sql.html +++ b/silk/templates/silk/sql.html @@ -108,6 +108,7 @@