Made MigrationRecorder cache has_table() result if django_migrations table exists.

This commit is contained in:
Tom Forbes 2023-05-23 18:05:31 +01:00 committed by Mariusz Felisiak
parent 9d756afb07
commit ea8cbca579
2 changed files with 19 additions and 1 deletions

View file

@ -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):
"""