mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #30023 -- Prevented SQLite schema alterations while foreign key checks are enabled.
Prior to this change foreign key constraint references could be left pointing at tables dropped during operations simulating unsupported table alterations because of an unexpected failure to disable foreign key constraint checks. SQLite3 does not allow disabling such checks while in a transaction so they must be disabled beforehand. Thanks ezaquarii for the report and Carlton and Tim for the review.
This commit is contained in:
parent
a394289b58
commit
315357ad25
8 changed files with 89 additions and 42 deletions
|
@ -25,12 +25,12 @@ class SchemaIndexesTests(TestCase):
|
|||
"""
|
||||
Index names should be deterministic.
|
||||
"""
|
||||
with connection.schema_editor() as editor:
|
||||
index_name = editor._create_index_name(
|
||||
table_name=Article._meta.db_table,
|
||||
column_names=("c1",),
|
||||
suffix="123",
|
||||
)
|
||||
editor = connection.schema_editor()
|
||||
index_name = editor._create_index_name(
|
||||
table_name=Article._meta.db_table,
|
||||
column_names=("c1",),
|
||||
suffix="123",
|
||||
)
|
||||
self.assertEqual(index_name, "indexes_article_c1_a52bd80b123")
|
||||
|
||||
def test_index_name(self):
|
||||
|
@ -41,12 +41,12 @@ class SchemaIndexesTests(TestCase):
|
|||
* Include a deterministic hash.
|
||||
"""
|
||||
long_name = 'l%sng' % ('o' * 100)
|
||||
with connection.schema_editor() as editor:
|
||||
index_name = editor._create_index_name(
|
||||
table_name=Article._meta.db_table,
|
||||
column_names=('c1', 'c2', long_name),
|
||||
suffix='ix',
|
||||
)
|
||||
editor = connection.schema_editor()
|
||||
index_name = editor._create_index_name(
|
||||
table_name=Article._meta.db_table,
|
||||
column_names=('c1', 'c2', long_name),
|
||||
suffix='ix',
|
||||
)
|
||||
expected = {
|
||||
'mysql': 'indexes_article_c1_c2_looooooooooooooooooo_255179b2ix',
|
||||
'oracle': 'indexes_a_c1_c2_loo_255179b2ix',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue