Merge "Tolerate null on Json db load"

This commit is contained in:
Jenkins 2014-10-22 02:53:58 +00:00 committed by Gerrit Code Review
commit 52870d148c
2 changed files with 14 additions and 0 deletions

View File

@ -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)

View File

@ -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)