Repository: rucio/rucio
Issue: dids: setting events with set_metadata fails

Motivation
----------
(cx_Oracle.NotSupportedError) Variable_TypeByValue(): unhandled data type result [SQL: u'UPDATE atlas_rucio.dids SET events=:events, updated_at=:updated_at WHERE atlas_rucio.dids.scope = :scope_1 AND atlas_rucio.dids.name = :name_1'] [parameters: {'events': (1000,), u'name_1': 'mc16_13TeV.364186.Sherpa_221_NNPDF30NNLO_Wtaunu_MAXHTPTV0_70_BFilter.simul.HITS.e5340_e5984_s3126_tid13424328_00', 'updated_at': datetime.datetime(2018, 3, 16, 11, 13, 6, 247121), u'scope_1': 'mc16_13TeV'}] (Background on this error at: http://sqlalche.me/e/tw8g)

Modification
------------

...one() --> .one()[0]

Changed files:
lib/rucio/core/did.py

diff --git a/lib/rucio/core/did.py b/lib/rucio/core/did.py
index b8caf00cb..3e6ee7959 100644
--- a/lib/rucio/core/did.py
+++ b/lib/rucio/core/did.py
@@ -1,22 +1,27 @@
-'''
-  Copyright European Organization for Nuclear Research (CERN)
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  You may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Authors:
-  - Vincent Garonne, <vincent.garonne@cern.ch>, 2012-2018
-  - Mario Lassnig, <mario.lassnig@cern.ch>, 2012-2015, 2017
-  - Yun-Pin Sun, <yun-pin.sun@cern.ch>, 2013
-  - Cedric Serfon, <cedric.serfon@cern.ch>, 2013-2015, 2017
-  - Martin Barisits, <martin.barisits@cern.ch>, 2013-2017
-  - Ralph Vigne, <ralph.vigne@cern.ch>, 2013
-  - Thomas Beermann, <thomas.beermann@cern.ch>, 2014, 2016-2018
-  - Joaquin Bogado, <joaquin.bogado@cern.ch>, 2014-2015
-  - Wen Guan, <wen.guan@cern.ch>, 2015
-'''
+# Copyright 2013-2018 CERN for the benefit of the ATLAS collaboration.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Authors:
+# - Vincent Garonne <vgaronne@gmail.com>, 2013-2018
+# - Martin Barisits <martin.barisits@cern.ch>, 2013-2017
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2013-2017
+# - Ralph Vigne <ralph.vigne@cern.ch>, 2013
+# - Mario Lassnig <mario.lassnig@cern.ch>, 2013-2018
+# - Yun-Pin Sun <winter0128@gmail.com>, 2013
+# - Thomas Beermann <thomas.beermann@cern.ch>, 2013-2018
+# - Joaquin Bogado <jbogado@linti.unlp.edu.ar>, 2014-2015
+# - Wen Guan <wguan.icedew@gmail.com>, 2015
 
 import logging
 import random
@@ -1170,7 +1175,7 @@ def set_metadata(scope, name, key, value, type=None, did=None,
         session.query(models.DataIdentifierAssociation).filter_by(child_scope=scope, child_name=name, child_type=DIDType.FILE).update({key: value}, synchronize_session=False)
         if key == 'events':
             for parent_scope, parent_name in session.query(models.DataIdentifierAssociation.scope, models.DataIdentifierAssociation.name).filter_by(child_scope=scope, child_name=name):
-                events = session.query(func.sum(models.DataIdentifierAssociation.events)).filter_by(scope=parent_scope, name=parent_name).one()
+                events = session.query(func.sum(models.DataIdentifierAssociation.events)).filter_by(scope=parent_scope, name=parent_name).one()[0]
                 session.query(models.DataIdentifier).filter_by(scope=parent_scope, name=parent_name).update({'events': events}, synchronize_session=False)
 
     elif key == 'adler32':