Handle NULL value for service.extra in migration 066
Added a check for service.extra column before jsonutils.loads() call Change-Id: I5a652101d986672ba6094f0b3e107e2710154c68 Closes-Bug: #1441164
This commit is contained in:
parent
3550b473a7
commit
4c879c9bc7
|
@ -22,7 +22,11 @@ def upgrade(migrate_engine):
|
|||
services = list(service_table.select().execute())
|
||||
|
||||
for service in services:
|
||||
extra_dict = jsonutils.loads(service.extra)
|
||||
if service.extra is not None:
|
||||
extra_dict = jsonutils.loads(service.extra)
|
||||
else:
|
||||
extra_dict = {}
|
||||
|
||||
# Skip records where service is not null
|
||||
if extra_dict.get('name') is not None:
|
||||
continue
|
||||
|
|
|
@ -512,6 +512,10 @@ class SqlUpgradeTests(SqlMigrateBase):
|
|||
random_attr_name_empty, random_attr_name_none_str),
|
||||
]
|
||||
|
||||
# NOTE(viktors): Add a service with empty extra field
|
||||
self.insert_dict(session, 'service',
|
||||
{'id': uuid.uuid4().hex, 'type': uuid.uuid4().hex})
|
||||
|
||||
session.close()
|
||||
self.upgrade(66)
|
||||
session = self.Session()
|
||||
|
|
Loading…
Reference in New Issue