Example #1
0
 def test_field_rename_inside_atomic_block(self):
     """
     NotImplementedError is raised when a model field rename is attempted
     inside an atomic block.
     """
     new_field = CharField(max_length=255, unique=True)
     new_field.set_attributes_from_name('renamed')
     msg = (
         "Renaming the 'backends_author'.'name' column while in a "
         "transaction is not supported on SQLite < 3.26 because it would "
         "break referential integrity. Try adding `atomic = False` to the "
         "Migration class.")
     with self.assertRaisesMessage(NotSupportedError, msg):
         with connection.schema_editor(atomic=True) as editor:
             editor.alter_field(Author, Author._meta.get_field('name'),
                                new_field)