Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debug_toolbar/panels/sql/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _record(self, method, sql, params):
"start_time": start_time,
"stop_time": stop_time,
"is_slow": duration > dt_settings.get_config()["SQL_WARNING_THRESHOLD"],
"is_select": sql.lower().strip().startswith("select"),
"is_select": force_text(sql).lower().strip().startswith("select"),
"template_info": template_info,
}

Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ coverage
flake8
html5lib
isort
psycopg2
selenium
tox

Expand Down
13 changes: 12 additions & 1 deletion tests/panels/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import datetime
import unittest
from psycopg2 import sql

from django.contrib.auth.models import User
from django.db import connection
from django.db import connection, connections
from django.db.models import Count
from django.db.utils import DatabaseError
from django.shortcuts import render
Expand Down Expand Up @@ -266,3 +267,13 @@ def test_regression_infinite_recursion(self):

# ensure the stacktrace is populated
self.assertTrue(len(query[1]["stacktrace"]) > 0)

@unittest.skipUnless(
connection.vendor == "postgresql", "Test valid only on PostgreSQL"
)
def test_composed_object(self):
self.assertEqual(len(self.panel._queries), 0)
query = sql.SQL("SELECT * FROM {}").format(sql.Identifier("auth_user"))
cursor = connections["postgresql"].cursor()
cursor.execute(query)
self.assertEqual(len(self.panel._queries), 1)