| 78 | |
| 79 | @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific") |
| 80 | def test_postgres_options(self): |
| 81 | qs = Tag.objects.filter(name="test") |
| 82 | test_options = [ |
| 83 | {"COSTS": False, "BUFFERS": True, "ANALYZE": True}, |
| 84 | {"costs": False, "buffers": True, "analyze": True}, |
| 85 | {"verbose": True, "timing": True, "analyze": True}, |
| 86 | {"verbose": False, "timing": False, "analyze": True}, |
| 87 | {"summary": True}, |
| 88 | {"settings": True}, |
| 89 | {"analyze": True, "wal": True}, |
| 90 | ] |
| 91 | if connection.features.is_postgresql_16: |
| 92 | test_options.append({"generic_plan": True}) |
| 93 | if connection.features.is_postgresql_17: |
| 94 | test_options.append({"memory": True}) |
| 95 | test_options.append({"serialize": "TEXT", "analyze": True}) |
| 96 | test_options.append({"serialize": "text", "analyze": True}) |
| 97 | test_options.append({"serialize": "BINARY", "analyze": True}) |
| 98 | test_options.append({"serialize": "binary", "analyze": True}) |
| 99 | for options in test_options: |
| 100 | with self.subTest(**options), transaction.atomic(): |
| 101 | with CaptureQueriesContext(connection) as captured_queries: |
| 102 | qs.explain(format="text", **options) |
| 103 | self.assertEqual(len(captured_queries), 1) |
| 104 | for name, value in options.items(): |
| 105 | if isinstance(value, str): |
| 106 | option = "{} {}".format(name.upper(), value.upper()) |
| 107 | else: |
| 108 | option = "{} {}".format( |
| 109 | name.upper(), "true" if value else "false" |
| 110 | ) |
| 111 | self.assertIn(option, captured_queries[0]["sql"]) |
| 112 | |
| 113 | @skipUnlessDBFeature("supports_select_union") |
| 114 | def test_multi_page_text_explain(self): |