mirror of
https://github.com/django/django.git
synced 2025-07-18 18:55:18 +00:00
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.
This commit is contained in:
parent
b09b71bf34
commit
928c12eb1a
8 changed files with 44 additions and 11 deletions
|
@ -309,6 +309,17 @@ class TestSerialization(PostgreSQLTestCase):
|
|||
self.assertEqual(instance.dates, DateRange(self.lower_date, self.upper_date))
|
||||
self.assertEqual(instance.timestamps, DateTimeTZRange(self.lower_dt, self.upper_dt))
|
||||
|
||||
def test_serialize_range_with_null(self):
|
||||
instance = RangesModel(ints=NumericRange(None, 10))
|
||||
data = serializers.serialize('json', [instance])
|
||||
new_instance = list(serializers.deserialize('json', data))[0].object
|
||||
self.assertEqual(new_instance.ints, NumericRange(None, 10))
|
||||
|
||||
instance = RangesModel(ints=NumericRange(10, None))
|
||||
data = serializers.serialize('json', [instance])
|
||||
new_instance = list(serializers.deserialize('json', data))[0].object
|
||||
self.assertEqual(new_instance.ints, NumericRange(10, None))
|
||||
|
||||
|
||||
class TestValidators(PostgreSQLTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue