Tolerate null on Json db load
A icehouse->juno migration issue has surfaced where resource.properties_data is null for existing resource records. This change fixes the Json db type to treat None the same as the serialized JSON 'null'. Change-Id: Ia0b9a23a7798c95fbbcba439ffb8203b50367e7c Closes-Bug: #1383505
This commit is contained in:
parent
a6e9a94c6c
commit
9b792fb6a3
@ -34,6 +34,8 @@ class Json(LongText):
|
||||
return dumps(value)
|
||||
|
||||
def process_result_value(self, value, dialect):
|
||||
if value is None:
|
||||
return None
|
||||
return loads(value)
|
||||
|
||||
|
||||
|
@ -47,8 +47,20 @@ class JsonTest(testtools.TestCase):
|
||||
result = self.sqltype.process_bind_param(value, dialect)
|
||||
self.assertEqual('{"foo": "bar"}', result)
|
||||
|
||||
def test_process_bind_param_null(self):
|
||||
dialect = None
|
||||
value = None
|
||||
result = self.sqltype.process_bind_param(value, dialect)
|
||||
self.assertEqual('null', result)
|
||||
|
||||
def test_process_result_value(self):
|
||||
dialect = None
|
||||
value = '{"foo": "bar"}'
|
||||
result = self.sqltype.process_result_value(value, dialect)
|
||||
self.assertEqual({'foo': 'bar'}, result)
|
||||
|
||||
def test_process_result_value_null(self):
|
||||
dialect = None
|
||||
value = None
|
||||
result = self.sqltype.process_result_value(value, dialect)
|
||||
self.assertIsNone(result)
|
||||
|
Loading…
Reference in New Issue
Block a user