diff --git a/tests/schema/models.py b/tests/schema/models.py
index 07b9496..d50caf9 100644
a
|
b
|
class Note(models.Model):
|
87 | 87 | apps = new_apps |
88 | 88 | |
89 | 89 | |
| 90 | class NoteRename(models.Model): |
| 91 | detail_info = models.TextField() |
| 92 | |
| 93 | class Meta: |
| 94 | apps = new_apps |
| 95 | db_table = "schema_note" |
| 96 | |
| 97 | |
90 | 98 | class Tag(models.Model): |
91 | 99 | title = models.CharField(max_length=255) |
92 | 100 | slug = models.SlugField(unique=True) |
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 67a3738..908a423 100644
a
|
b
|
from django.test import TransactionTestCase, skipIfDBFeature
|
20 | 20 | from .fields import CustomManyToManyField, InheritedManyToManyField |
21 | 21 | from .models import ( |
22 | 22 | Author, AuthorWithDefaultHeight, AuthorWithEvenLongerName, Book, BookWeak, |
23 | | BookWithLongName, BookWithO2O, BookWithSlug, Note, Tag, TagIndexed, |
| 23 | BookWithLongName, BookWithO2O, BookWithSlug, Note, NoteRename, Tag, TagIndexed, |
24 | 24 | TagM2MTest, TagUniqueRename, Thing, UniqueTest, new_apps, |
25 | 25 | ) |
26 | 26 | |
… |
… |
class SchemaTests(TransactionTestCase):
|
751 | 751 | self.assertEqual(columns['display_name'][0], "CharField") |
752 | 752 | self.assertNotIn("name", columns) |
753 | 753 | |
| 754 | @skipIfDBFeature('interprets_empty_strings_as_nulls') |
| 755 | def test_rename_keep_null_status(self): |
| 756 | """ |
| 757 | Renaming a field shouldn't affect the not null status. |
| 758 | """ |
| 759 | with connection.schema_editor() as editor: |
| 760 | editor.create_model(Note) |
| 761 | with self.assertRaises(IntegrityError): |
| 762 | Note.objects.create(info=None) |
| 763 | old_field = Note._meta.get_field("info") |
| 764 | new_field = TextField() |
| 765 | new_field.set_attributes_from_name("detail_info") |
| 766 | with connection.schema_editor() as editor: |
| 767 | editor.alter_field(Note, old_field, new_field, strict=True) |
| 768 | columns = self.column_classes(Note) |
| 769 | self.assertEqual(columns['detail_info'][0], "TextField") |
| 770 | self.assertNotIn("info", columns) |
| 771 | with self.assertRaises(IntegrityError): |
| 772 | NoteRename.objects.create(detail_info=None) |
| 773 | |
754 | 774 | def _test_m2m_create(self, M2MFieldClass): |
755 | 775 | """ |
756 | 776 | Tests M2M fields on models during creation |