diff --git a/explorer/tests/test_views.py b/explorer/tests/test_views.py index 1127d179..cb0f7790 100644 --- a/explorer/tests/test_views.py +++ b/explorer/tests/test_views.py @@ -109,6 +109,11 @@ def test_playground_renders_with_posted_sql(self): self.assertTemplateUsed(resp, 'explorer/play.html') self.assertContains(resp, 'select 1;') + def test_query_with_no_resultset_doesnt_throw_error(self): + query = SimpleQueryFactory(sql="") + resp = self.client.get('%s?query_id=%s' % (reverse("explorer_playground"), query.id)) + self.assertTemplateUsed(resp, 'explorer/play.html') + def test_admin_required(self): self.client.logout() resp = self.client.get(reverse("explorer_playground")) diff --git a/explorer/utils.py b/explorer/utils.py index 691976a0..25013d53 100644 --- a/explorer/utils.py +++ b/explorer/utils.py @@ -36,7 +36,7 @@ def execute_query(sql): def execute_and_fetch_query(sql): cursor, duration = execute_query(sql) - headers = [d[0] for d in cursor.description] + headers = [d[0] for d in cursor.description] if cursor.description else ['--'] data = [[x.encode('utf-8') if type(x) is unicode else x for x in list(r)] for r in cursor.fetchall()] return headers, data, duration, None