Fixed #31805 -- Fixed SchemaTests.tearDown() when table names are case-insensitive.

This commit is contained in:
Mariusz Felisiak 2020-07-22 12:49:56 +02:00 committed by GitHub
parent c071c408d7
commit fd53db842c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -88,8 +88,12 @@ class SchemaTests(TransactionTestCase):
with connection.schema_editor() as editor: with connection.schema_editor() as editor:
connection.disable_constraint_checking() connection.disable_constraint_checking()
table_names = connection.introspection.table_names() table_names = connection.introspection.table_names()
if connection.features.ignores_table_name_case:
table_names = [table_name.lower() for table_name in table_names]
for model in itertools.chain(SchemaTests.models, self.local_models): for model in itertools.chain(SchemaTests.models, self.local_models):
tbl = converter(model._meta.db_table) tbl = converter(model._meta.db_table)
if connection.features.ignores_table_name_case:
tbl = tbl.lower()
if tbl in table_names: if tbl in table_names:
editor.delete_model(model) editor.delete_model(model)
table_names.remove(tbl) table_names.remove(tbl)