mirror of
https://github.com/django/django.git
synced 2025-08-31 15:57:45 +00:00
Fixed #30108 -- Allowed adding foreign key constraints in the same statement that adds a field.
This commit is contained in:
parent
9a0cc54524
commit
738faf9da2
9 changed files with 69 additions and 20 deletions
|
@ -226,11 +226,9 @@ class SchemaIndexesMySQLTests(TransactionTestCase):
|
|||
new_field.set_attributes_from_name('new_foreign_key')
|
||||
editor.add_field(ArticleTranslation, new_field)
|
||||
field_created = True
|
||||
self.assertEqual([str(statement) for statement in editor.deferred_sql], [
|
||||
'ALTER TABLE `indexes_articletranslation` '
|
||||
'ADD CONSTRAINT `indexes_articletrans_new_foreign_key_id_d27a9146_fk_indexes_a` '
|
||||
'FOREIGN KEY (`new_foreign_key_id`) REFERENCES `indexes_article` (`id`)'
|
||||
])
|
||||
# No deferred SQL. The FK constraint is included in the
|
||||
# statement to add the field.
|
||||
self.assertFalse(editor.deferred_sql)
|
||||
finally:
|
||||
if field_created:
|
||||
with connection.schema_editor() as editor:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue