From 0773b0d232292991018fae520556b1d4a90efbed Mon Sep 17 00:00:00 2001 From: Alan Malta Rodrigues Date: Fri, 10 Jun 2022 09:08:55 -0400 Subject: [PATCH] Ensure dataset_lifetime bind is defined for DBS3Buffer/NewSubscription get dict key safely --- src/python/WMComponent/DBS3Buffer/MySQL/NewSubscription.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/python/WMComponent/DBS3Buffer/MySQL/NewSubscription.py b/src/python/WMComponent/DBS3Buffer/MySQL/NewSubscription.py index 1529e1aa27..6a8212d395 100644 --- a/src/python/WMComponent/DBS3Buffer/MySQL/NewSubscription.py +++ b/src/python/WMComponent/DBS3Buffer/MySQL/NewSubscription.py @@ -39,6 +39,8 @@ def _createPhEDExSubBinds(self, datasetID, subscriptionInfo, custodialFlag): # DeleteFromSource is not supported for move subscriptions delete_blocks = None + # if None, force it to 0 as per the table schema + dataLifetime = subscriptionInfo.get('DatasetLifetime', 0) or 0 if custodialFlag: sites = subscriptionInfo['CustodialSites'] phedex_group = subscriptionInfo['CustodialGroup'] @@ -59,9 +61,8 @@ def _createPhEDExSubBinds(self, datasetID, subscriptionInfo, custodialFlag): 'move': isMove, 'priority': subscriptionInfo['Priority'], 'phedex_group': phedex_group, - 'delete_blocks': delete_blocks} - if subscriptionInfo['DatasetLifetime'] is not None: - bind.update(dict(dataset_lifetime=subscriptionInfo['DatasetLifetime'])) + 'delete_blocks': delete_blocks, + 'dataset_lifetime': dataLifetime} binds.append(bind) return binds