diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-06-16 18:43:45 -0700 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-06-16 18:44:22 -0700 |
| commit | 6e7da2bfafb63f5f7c35ed281807cdb54794c2f0 (patch) | |
| tree | ce61dec6910f69aac8881486574da3aaa11fa361 /tests | |
| parent | dc7d0f50e22bc52bc4656879452c482394347b75 (diff) | |
[1.7.x] Fixed #22851: BinaryView wasn't getting a binary default
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/schema/tests.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 624ada5276..f3b9423147 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -4,9 +4,10 @@ import unittest from django.test import TransactionTestCase from django.db import connection, DatabaseError, IntegrityError, OperationalError -from django.db.models.fields import IntegerField, TextField, CharField, SlugField, BooleanField +from django.db.models.fields import IntegerField, TextField, CharField, SlugField, BooleanField, BinaryField from django.db.models.fields.related import ManyToManyField, ForeignKey from django.db.transaction import atomic +from django.utils import six from .models import (Author, AuthorWithM2M, Book, BookWithLongName, BookWithSlug, BookWithM2M, Tag, TagIndexed, TagM2MTest, TagUniqueRename, UniqueTest, Thing, TagThrough, BookWithM2MThrough, AuthorTag, AuthorWithM2MThrough) @@ -269,6 +270,25 @@ class SchemaTests(TransactionTestCase): # Make sure the values were transformed correctly self.assertEqual(Author.objects.extra(where=["thing = 1"]).count(), 2) + def test_add_field_binary(self): + """ + Tests binary fields get a sane default (#22851) + """ + # Create the table + with connection.schema_editor() as editor: + editor.create_model(Author) + # Add the new field + new_field = BinaryField(blank=True) + new_field.set_attributes_from_name("bits") + with connection.schema_editor() as editor: + editor.add_field( + Author, + new_field, + ) + # Ensure the field is right afterwards + columns = self.column_classes(Author) + self.assertEqual(columns['bits'][0], "BinaryField") + def test_alter(self): """ Tests simple altering of fields |
