MCPcopy
hub / github.com/django/django / test_mysql_analyze

Method test_mysql_analyze

tests/queries/test_explain.py:163–176  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

161
162 @unittest.skipUnless(connection.vendor == "mysql", "MySQL specific")
163 def test_mysql_analyze(self):
164 qs = Tag.objects.filter(name="test")
165 with CaptureQueriesContext(connection) as captured_queries:
166 qs.explain(analyze=True)
167 self.assertEqual(len(captured_queries), 1)
168 prefix = "ANALYZE " if connection.mysql_is_mariadb else "EXPLAIN ANALYZE "
169 self.assertTrue(captured_queries[0]["sql"].startswith(prefix))
170 with CaptureQueriesContext(connection) as captured_queries:
171 qs.explain(analyze=True, format="JSON")
172 self.assertEqual(len(captured_queries), 1)
173 if connection.mysql_is_mariadb:
174 self.assertIn("FORMAT=JSON", captured_queries[0]["sql"])
175 else:
176 self.assertNotIn("FORMAT=JSON", captured_queries[0]["sql"])
177
178
179@skipIfDBFeature("supports_explaining_query_execution")

Callers

nothing calls this directly

Calls 3

filterMethod · 0.45
explainMethod · 0.45

Tested by

no test coverage detected