Kaydet (Commit) a7c58eac authored tarafından Daan Vielen's avatar Daan Vielen

added test and fix to check for default null on ArrayField

üst 39e3ef88
...@@ -100,7 +100,7 @@ class ArrayField(Field): ...@@ -100,7 +100,7 @@ class ArrayField(Field):
if callable(self.default): if callable(self.default):
return self.default() return self.default()
return self.default return self.default
return '' return None
def value_to_string(self, obj): def value_to_string(self, obj):
values = [] values = []
......
...@@ -48,6 +48,13 @@ class TestSaveLoad(TestCase): ...@@ -48,6 +48,13 @@ class TestSaveLoad(TestCase):
loaded = IntegerArrayModel.objects.get() loaded = IntegerArrayModel.objects.get()
self.assertEqual(loaded.field, [1]) 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): def test_null_handling(self):
instance = NullableIntegerArrayModel(field=None) instance = NullableIntegerArrayModel(field=None)
instance.save() instance.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment