mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #24846 -- Added support to MySQL SchemaEditor for all blob/text data types
This commit is contained in:
@@ -17,7 +17,9 @@ from django.db.models.fields.related import (
|
||||
from django.db.transaction import atomic
|
||||
from django.test import TransactionTestCase, skipIfDBFeature
|
||||
|
||||
from .fields import CustomManyToManyField, InheritedManyToManyField
|
||||
from .fields import (
|
||||
CustomManyToManyField, InheritedManyToManyField, MediumBlobField,
|
||||
)
|
||||
from .models import (
|
||||
Author, AuthorWithDefaultHeight, AuthorWithEvenLongerName, Book, BookWeak,
|
||||
BookWithLongName, BookWithO2O, BookWithSlug, Note, NoteRename, Tag,
|
||||
@@ -383,6 +385,23 @@ class SchemaTests(TransactionTestCase):
|
||||
# these two types.
|
||||
self.assertIn(columns['bits'][0], ("BinaryField", "TextField"))
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'mysql', "MySQL specific")
|
||||
def test_add_binaryfield_mediumblob(self):
|
||||
"""
|
||||
Test adding a custom-sized binary field on MySQL (#24846).
|
||||
"""
|
||||
# Create the table
|
||||
with connection.schema_editor() as editor:
|
||||
editor.create_model(Author)
|
||||
# Add the new field with default
|
||||
new_field = MediumBlobField(blank=True, default=b'123')
|
||||
new_field.set_attributes_from_name('bits')
|
||||
with connection.schema_editor() as editor:
|
||||
editor.add_field(Author, new_field)
|
||||
columns = self.column_classes(Author)
|
||||
# Introspection treats BLOBs as TextFields
|
||||
self.assertEqual(columns['bits'][0], "TextField")
|
||||
|
||||
def test_alter(self):
|
||||
"""
|
||||
Tests simple altering of fields
|
||||
|
||||
Reference in New Issue
Block a user