1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

[1.7.x] Fixed #23920 -- Fixed MySQL crash when adding blank=True to TextField.

Thanks wkornewald for the report and Markus Holtermann for review.

Backport of 765fa36d57 from master
This commit is contained in:
Tim Graham
2014-12-04 09:11:30 -05:00
parent e8c88c93ec
commit d57124433f
4 changed files with 23 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ from django.db.transaction import atomic
from .models import (Author, AuthorWithDefaultHeight, AuthorWithM2M, Book, BookWithLongName,
BookWithSlug, BookWithM2M, Tag, TagIndexed, TagM2MTest, TagUniqueRename,
UniqueTest, Thing, TagThrough, BookWithM2MThrough, AuthorTag, AuthorWithM2MThrough,
AuthorWithEvenLongerName, BookWeak)
AuthorWithEvenLongerName, BookWeak, Note)
class SchemaTests(TransactionTestCase):
@@ -423,6 +423,19 @@ class SchemaTests(TransactionTestCase):
self.assertEqual(columns['name'][0], "TextField")
self.assertEqual(bool(columns['name'][1][6]), False)
def test_alter_text_field(self):
# Regression for "BLOB/TEXT column 'info' can't have a default value")
# on MySQL.
new_field = TextField(blank=True)
new_field.set_attributes_from_name("info")
with connection.schema_editor() as editor:
editor.alter_field(
Note,
Note._meta.get_field_by_name("info")[0],
new_field,
strict=True,
)
def test_alter_null_to_not_null(self):
"""
#23609 - Tests handling of default values when altering from NULL to NOT NULL.