Merge "Tolerate null on Json db load"
This commit is contained in:
commit
52870d148c
@ -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