Merge pull request #3531 from ddaan/ticket_23834

fixed #23834 -- added test and fix to check for default null on ArrayField
This commit is contained in:
Marc Tamlyn 2014-11-15 15:37:03 +00:00
commit 9a5a4361c5
2 changed files with 8 additions and 1 deletions

View File

@ -100,7 +100,7 @@ class ArrayField(Field):
if callable(self.default):
return self.default()
return self.default
return ''
return None
def value_to_string(self, obj):
values = []

View File

@ -48,6 +48,13 @@ class TestSaveLoad(TestCase):
loaded = IntegerArrayModel.objects.get()
self.assertEqual(loaded.field, [1])
def test_default_null(self):
instance = NullableIntegerArrayModel()
instance.save()
loaded = NullableIntegerArrayModel.objects.get(pk=instance.pk)
self.assertEqual(loaded.field, None)
self.assertEqual(instance.field, loaded.field)
def test_null_handling(self):
instance = NullableIntegerArrayModel(field=None)
instance.save()