mirror of
https://github.com/django/django.git
synced 2025-08-18 01:30:42 +00:00
[1.9.x] Fixed #26215 -- Fixed RangeField/ArrayField serialization with None values
Also added tests for HStoreField and JSONField.
Thanks Aleksey Bukin for the report and Tim Graham for the initial patch and
the review.
Backport of 928c12eb1
from master.
This commit is contained in:
parent
cc7ea1905d
commit
205cafd01e
8 changed files with 44 additions and 11 deletions
|
@ -213,16 +213,16 @@ class TestQuerying(TestCase):
|
|||
|
||||
@skipUnlessPG94
|
||||
class TestSerialization(TestCase):
|
||||
test_data = '[{"fields": {"field": {"a": "b"}}, "model": "postgres_tests.jsonmodel", "pk": null}]'
|
||||
test_data = '[{"fields": {"field": {"a": "b", "c": null}}, "model": "postgres_tests.jsonmodel", "pk": null}]'
|
||||
|
||||
def test_dumping(self):
|
||||
instance = JSONModel(field={'a': 'b'})
|
||||
instance = JSONModel(field={'a': 'b', 'c': None})
|
||||
data = serializers.serialize('json', [instance])
|
||||
self.assertJSONEqual(data, self.test_data)
|
||||
|
||||
def test_loading(self):
|
||||
instance = list(serializers.deserialize('json', self.test_data))[0].object
|
||||
self.assertEqual(instance.field, {'a': 'b'})
|
||||
self.assertEqual(instance.field, {'a': 'b', 'c': None})
|
||||
|
||||
|
||||
class TestValidation(PostgreSQLTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue