(self)
| 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") |
nothing calls this directly
no test coverage detected