1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #27582 -- Allowed HStoreField to store null values.

This commit is contained in:
David Hoffman
2016-12-08 19:17:02 -05:00
committed by Tim Graham
parent 9524fd9133
commit bf84d042e0
6 changed files with 33 additions and 9 deletions

View File

@@ -195,7 +195,11 @@ class TestValidation(HStoreTestCase):
with self.assertRaises(exceptions.ValidationError) as cm:
field.clean({'a': 1}, None)
self.assertEqual(cm.exception.code, 'not_a_string')
self.assertEqual(cm.exception.message % cm.exception.params, 'The value of "a" is not a string.')
self.assertEqual(cm.exception.message % cm.exception.params, 'The value of "a" is not a string or null.')
def test_none_allowed_as_value(self):
field = HStoreField()
self.assertEqual(field.clean({'a': None}, None), {'a': None})
class TestFormField(HStoreTestCase):
@@ -224,6 +228,11 @@ class TestFormField(HStoreTestCase):
value = field.clean('{"a": 1}')
self.assertEqual(value, {'a': '1'})
def test_none_value(self):
field = forms.HStoreField()
value = field.clean('{"a": null}')
self.assertEqual(value, {'a': None})
def test_empty(self):
field = forms.HStoreField(required=False)
value = field.clean('')