From ea8cbca579cc6742e119747fc1eb6ecf90638bce Mon Sep 17 00:00:00 2001 From: Tom Forbes Date: Tue, 23 May 2023 18:05:31 +0100 Subject: Made MigrationRecorder cache has_table() result if django_migrations table exists. --- tests/migrations/test_loader.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py index 800d715bc9..24e1e98c19 100644 --- a/tests/migrations/test_loader.py +++ b/tests/migrations/test_loader.py @@ -48,6 +48,16 @@ class RecorderTests(TestCase): set(), ) + def test_has_table_cached(self): + """ + The has_table() method caches a positive result and not continually + query for the existence of the migrations table. + """ + recorder = MigrationRecorder(connection) + with self.assertNumQueries(1): + self.assertEqual(recorder.has_table(), True) + self.assertEqual(recorder.has_table(), True) + class LoaderTests(TestCase): """ -- cgit v1.3