mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #35448 -- Fixed formatting of test --debug-sql output.
Also adds DatabaseOperations.format_debug_sql() hook for backends (e.g. NoSQL) to customize formatting.
This commit is contained in:
committed by
Mariusz Felisiak
parent
98767ba2ec
commit
d8f093908c
@@ -77,7 +77,12 @@ class LastExecutedQueryTest(TestCase):
|
||||
connection.ops.last_executed_query(cursor, "", ())
|
||||
|
||||
def test_debug_sql(self):
|
||||
list(Reporter.objects.filter(first_name="test"))
|
||||
qs = Reporter.objects.filter(first_name="test")
|
||||
ops = connections[qs.db].ops
|
||||
with mock.patch.object(ops, "format_debug_sql") as format_debug_sql:
|
||||
list(qs)
|
||||
# Queries are formatted with DatabaseOperations.format_debug_sql().
|
||||
format_debug_sql.assert_called()
|
||||
sql = connection.queries[-1]["sql"].lower()
|
||||
self.assertIn("select", sql)
|
||||
self.assertIn(Reporter._meta.db_table, sql)
|
||||
|
||||
Reference in New Issue
Block a user