mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
Applied db_table conversion to fix schema tests on Oracle.
This commit is contained in:
parent
492537ac18
commit
7c637a3aae
@ -63,6 +63,7 @@ class SchemaTests(TransactionTestCase):
|
|||||||
|
|
||||||
def delete_tables(self):
|
def delete_tables(self):
|
||||||
"Deletes all model tables for our models for a clean test environment"
|
"Deletes all model tables for our models for a clean test environment"
|
||||||
|
converter = connection.introspection.table_name_converter
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
connection.disable_constraint_checking()
|
connection.disable_constraint_checking()
|
||||||
table_names = connection.introspection.table_names(cursor)
|
table_names = connection.introspection.table_names(cursor)
|
||||||
@ -70,7 +71,7 @@ class SchemaTests(TransactionTestCase):
|
|||||||
# Remove any M2M tables first
|
# Remove any M2M tables first
|
||||||
for field in model._meta.local_many_to_many:
|
for field in model._meta.local_many_to_many:
|
||||||
with atomic():
|
with atomic():
|
||||||
tbl = field.remote_field.through._meta.db_table
|
tbl = converter(field.remote_field.through._meta.db_table)
|
||||||
if tbl in table_names:
|
if tbl in table_names:
|
||||||
cursor.execute(connection.schema_editor().sql_delete_table % {
|
cursor.execute(connection.schema_editor().sql_delete_table % {
|
||||||
"table": connection.ops.quote_name(tbl),
|
"table": connection.ops.quote_name(tbl),
|
||||||
@ -78,7 +79,7 @@ class SchemaTests(TransactionTestCase):
|
|||||||
table_names.remove(tbl)
|
table_names.remove(tbl)
|
||||||
# Then remove the main tables
|
# Then remove the main tables
|
||||||
with atomic():
|
with atomic():
|
||||||
tbl = model._meta.db_table
|
tbl = converter(model._meta.db_table)
|
||||||
if tbl in table_names:
|
if tbl in table_names:
|
||||||
cursor.execute(connection.schema_editor().sql_delete_table % {
|
cursor.execute(connection.schema_editor().sql_delete_table % {
|
||||||
"table": connection.ops.quote_name(tbl),
|
"table": connection.ops.quote_name(tbl),
|
||||||
|
Loading…
Reference in New Issue
Block a user